Search:

Type: Posts; User: ghoul

Page 1 of 3 1 2 3

Search: Search took 0.01 seconds.

  1. Replies
    5
    Views
    163

    Okay, got it now. What this code does is...

    Okay, got it now.

    What this code does is essentially to loop through an array of strings or a list of strings. This list/array does have a sentinel value at the end, though. It is possible to...
  2. Replies
    5
    Views
    163

    Didn't quite get the part about the compiler but...

    Didn't quite get the part about the compiler but I suppose the code should be equivalent to this:




    #include <stdio.h>
    #include <string.h>


    int main()
  3. Replies
    5
    Views
    163

    String testing equality

    I have a code like the below, based on another similar code from the internet. Now, this code uses the not equal operator to compare between string while, to my knowledge, 'strcmp' should be what to...
  4. Replies
    4
    Views
    197

    Noticed this after making the post here: ...

    Noticed this after making the post here:



    char **result = malloc(sizeof(char));


    And was even more surprised that code was working... What exactly was happening?

    So, I have this, let...
  5. Replies
    4
    Views
    197

    Critique my string splitting API

    Hello,

    This is probably petty, if not very petty but...

    Can someone critique my string splitting API.




    #include <stdio.h>
  6. Thread: Code refactor

    by ghoul
    Replies
    5
    Views
    434

    I agree with the use 'const' here but why did you...

    I agree with the use 'const' here but why did you use the storage specifier 'static' in this context? Is it really necessary? I don't understand...
  7. Thread: Code refactor

    by ghoul
    Replies
    5
    Views
    434

    Code refactor

    Hello friends,

    I am tasked with refactoring the following code so that is it is easily maintainable.



    #include "libs.hpp"
  8. Replies
    10
    Views
    771

    It sounds like the libpng API should be what...

    It sounds like the libpng API should be what you're interested in. Am I wrong?
  9. Replies
    13
    Views
    689

    Just ask right here...

    Just ask right here...
  10. Replies
    8
    Views
    744

    Since you are only concerned with object files,...

    Since you are only concerned with object files, not using a library would be okay too but the library would come in handy when you have a large number of file types to detect.
  11. Replies
    8
    Views
    744

    My resumption is that you are on Linux where you...

    My resumption is that you are on Linux where you can use libmagic.
  12. Replies
    3
    Views
    424

    The warning has no implications on your side. To...

    The warning has no implications on your side. To get around it you can cast your string to const char *
    if (strcmp((const char *)text.value, "xterm") != 0)

    By the way should that be:

    ...
  13. Thread: Macro help

    by ghoul
    Replies
    3
    Views
    586

    Thanks, the term variadic saved me there. It...

    Thanks, the term variadic saved me there. It seems like they work with -std=gcc89? Is that ten years before C99? Well.



    Thanks a lot. This time, for me, it is actually not necessary because...
  14. Thread: Macro help

    by ghoul
    Replies
    3
    Views
    586

    Macro help

    Hello,

    My macro looks like this:




    #include <stdio.h>
    #include <stdbool.h>
  15. Replies
    3
    Views
    743

    Thanks for your input. Good question

    Thanks for your input.



    Good question
  16. Replies
    3
    Views
    743

    Determine the type of a struct at runtime

    Hello,

    My data is coming in the form of a pointer to void. My aim is to dump the data to stderr in a structured way. The data pointed to by the struct is a struct that could be of several types....
  17. That sounds like a decent strategy to me. ...

    That sounds like a decent strategy to me.

    Some would say it is hacky but away from the scholary world, no-one cares for code for as long it implements functionality, patterns etc as expected.
  18. There is a chance that my familiarity with this...

    There is a chance that my familiarity with this subject does not qualify me to comment on this but.

    C++ code implementing certain patterns compared to C code implementing the same pattern or even...
  19. Replies
    15
    Views
    1,337

    It is as easy as it sounds. Make them point to...

    It is as easy as it sounds. Make them point to the same address.




    ListNode *node = malloc(sizeof(ListNode));

    List->Head = node;
    List->Tail = node;
  20. Replies
    15
    Views
    1,337

    To me it sounds much better if put like this :->...

    To me it sounds much better if put like this :-> To insert a node at a certain index in the list. That way you accomplish the overall functionality of being able to insert anywhere on the list.
  21. Replies
    15
    Views
    1,337

    That initializes the variables in 'LinkedList' to...

    That initializes the variables in 'LinkedList' to NULL. After this this, the pointer List.Head and List.Tail are both NULL.

    Kindly note the declaration declares a 'LinkedList' object on the stack...
  22. You might as well think of them as two completely...

    You might as well think of them as two completely different development languages. Like you will usually find me doing.

    o.O
  23. Replies
    4
    Views
    639

    What have you tried? Do you have any code that...

    What have you tried? Do you have any code that you can show?

    My advice would be to use getline() to read the first line then discard/no put the line into any use.



    ...
  24. Haha. Interdersting. Had to try this out. It...

    Haha. Interdersting. Had to try this out. It actually works, yes.

    It would have been great to test this out with clang but:



    Testsqrt.c:24:5: error: non-void function 'sqrt_function' should...
  25. Replies
    9
    Views
    1,000

    It is not immediately clear to me, at least based...

    It is not immediately clear to me, at least based on this piece of code why they are passing a double pointer and not just a pointer to the function. AFAIK, double pointers are used when working with...
Results 1 to 25 of 58
Page 1 of 3 1 2 3