Search:

Type: Posts; User: john.c

Page 1 of 20 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    5
    Views
    87

    From C11 draft standard:

    From C11 draft standard:
  2. It might be a good idea to use defines in a...

    It might be a good idea to use defines in a header file.


    // header file
    #define Cmd_GetVersion "ER_CMD#T3"
    #define Cmd_GetPower "ER_CMD#P?"


    // code file
    strncpy(s_LPRS.command,...
  3. Apparently the size of a pointer on your device...

    Apparently the size of a pointer on your device is 2 bytes. So sizeof(c), where c is a pointer to char, is 2. sizeof(*c), the size of what c points to, will be 1.

    As long as TRANSMIT_SIZE is at...
  4. Thread: Issue on coding

    by john.c
    Replies
    5
    Views
    112

    You need to use strcpy to copy characters from...

    You need to use strcpy to copy characters from one string to another. You can't just use assignment.

    Assignment can be used if you are just copying pointers to strings without actually copying...
  5. Replies
    1
    Views
    82

    You need to get rid of the global variables!...

    You need to get rid of the global variables! That's just bad programming. Make a List struct, init it in main and pass it around.

    I think maybe the structure of your list is wrong. You have a...
  6. Replies
    4
    Views
    286

    Now that I think about it, my solution is pretty...

    Now that I think about it, my solution is pretty bad. I also forgot this was the C++ forum, so I didn't consider std::array.

    It does make sense that they are probably constants. For the string...
  7. Replies
    4
    Views
    286

    You can't take the sizeof an incomplete type....

    You can't take the sizeof an incomplete type.
    You can add something like this after your array definition:


    const int strings_size = sizeof strings / sizeof strings[0];

    and then in the other...
  8. Replies
    5
    Views
    143

    Qt is available under open source licenses...

    Qt is available under open source licenses (GPL2.0, GPL3.0, LGPL3.0).

    You can google for GTK forums (I know of no secret ones).
  9. Replies
    5
    Views
    143

    Qt official: Qt | Cross-platform software...

    Qt
    official: Qt | Cross-platform software development for embedded & desktop
    wikipedia: Qt (software) - Wikipedia

    GTK
    official: The GTK Project - A free and open-source cross-platform...
  10. Replies
    5
    Views
    175

    No, it doesn't compile. Zeus is confused between...

    No, it doesn't compile. Zeus is confused between C++ and C.
    Your code is correct, although using ++ is more usual.


    Passing a pointer to the first element is essentially passing the whole array...
  11. Please post actual code that you've ran then...

    Please post actual code that you've ran then copy/pasted, not something you just typed up. :tongue:

    What is inbuf? What is newline? (Presumably inbuffer and n.)
    And you have a semicolon in one...
  12. Replies
    6
    Views
    186

    Look at all three posts by this weirdo, this post...

    Look at all three posts by this weirdo, this post and the following two, all posted at about the same time.
    They are all meaningless garbage and remind me of the kind of useless add-on comments that...
  13. Replies
    15
    Views
    295

    Sure, post the GitHub link and the other stuff. ...

    Sure, post the GitHub link and the other stuff.

    @rstanley, Large multi-file programs are probably best posted as a link.
  14. It struck me as an old-fashioned style. Maybe...

    It struck me as an old-fashioned style. Maybe you're using an old book. Or have an old teacher. Whatever. :p
  15. It's the arbitrary actions of UB stemming from...

    It's the arbitrary actions of UB stemming from the uninitialized "top" pointer in "rev". It needs to be initialized to NULL.
  16. Replies
    8
    Views
    232

    You've been given more than enough information in...

    You've been given more than enough information in your thread on the other site: how read the GIF and JPG image size? - C++ Forum

    And from the code you've shown you clearly don't know what you...
  17. It's pretty obvious you didn't write that code.

    It's pretty obvious you didn't write that code.
  18. Replies
    2
    Views
    115

    It says that unsigned integers are supposed to...

    It says that unsigned integers are supposed to function the same across all implementations. It doesn't say anything about "testing for overflow of unsigned integers". In fact, you might say that...
  19. No. If curr could just be a single-level pointer...

    No. If curr could just be a single-level pointer I would've wrote it that way since it would be simpler. The reason you need the second level of indirection is that we don't want curr to hold the...
  20. The recursive version is better written like...

    The recursive version is better written like this:


    ListNode *merge2(ListNode *a, ListNode *b )
    {
    if (!a) return b;
    if (!b) return a;

    if (a->data <= b->data)
    {
  21. typedef struct listnode { char data; ...

    typedef struct listnode {
    char data;
    struct listnode *next;
    } ListNode;




    ListNode *merge(ListNode *a, ListNode *b)
    {
  22. Replies
    3
    Views
    148

    The format specs that read ints and floats and...

    The format specs that read ints and floats and the format spec "%s" all skip initial whitespace so there's no difference in functionality.
    Maybe your version is more readable, though.
  23. Replies
    3
    Views
    148

    We usually handle this kind of thing by first...

    We usually handle this kind of thing by first reading the entire line as a string, and then using sscanf to "scan" the numbers from the string. All the scanf functions return a count of the number of...
  24. Replies
    9
    Views
    173

    The format spec for long long is "%lld". You have...

    The format spec for long long is "%lld". You have "%ld", which is for long.

    If long long is actually bigger than long on your machine and your machine is little endian, then a 0 output for a...
  25. Don't just say "and the second problem is that it...

    Don't just say "and the second problem is that it does not work". Of course it "works". Post your broken code that you actually ran so we can show you your error. :mad:
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4