Search:

Type: Posts; User: christop

Page 1 of 20 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    1
    Views
    105

    I'd go with the most straightforward solution as...

    I'd go with the most straightforward solution as it's not a terribly complicated operation:


    int number_of_slots_that_have_something_other_than_0xff(const unsigned char array[50])
    {
    int...
  2. This isn't the only problem, but fgetc() returns...

    This isn't the only problem, but fgetc() returns int (not char), so c also needs to be declared as int.
  3. I'm not 100% sure, no. Is that considered a true...

    I'm not 100% sure, no. Is that considered a true VLA, though? I thought (perhaps mistakenly) that a VLA was only an automatic variable array whose size was determined at run time. A function...
  4. C99 and later support this type of function...

    C99 and later support this type of function declaration:



    void how(int x, int y, int array[x][y]);


    Then you just have to pass in the two dimensions (x and y) of the array when you call it....
  5. Also, PINs (also IDs, SSNs, phone numbers, etc.)...

    Also, PINs (also IDs, SSNs, phone numbers, etc.) should not be treated as numbers, even though they are numeric. They should be strings. Your example gives a good reason: if the user enters something...
  6. Tail call optimization is not guaranteed by C, so...

    Tail call optimization is not guaranteed by C, so you are very likely running into a call stack limit as @jimblumberg pointed out.
  7. Well yes of course, but OP already decided to use...

    Well yes of course, but OP already decided to use "static" which avoids that problem altogether.
  8. Ah, I read the description as if a...

    Ah, I read the description as if a comma-separated pair of numbers was called a "word". I suppose the assignment could be intended to have actual words on the input as you described. That definitely...
  9. Can you use sscanf to split each "word" in a line...

    Can you use sscanf to split each "word" in a line into numbers?


    double a, b;
    char *word = line;
    int n, offset;
    while ((n = sscanf(word, "%lf,%lf%n", &a, &b, &offset)) == 2) {
    word +=...
  10. Only if the function is also called from an...

    Only if the function is also called from an interrupt handler. If the function isn't used by any interrupt handler (only by the main code), there's no need to disable interrupts.
  11. Replies
    19
    Views
    714

    Just a wild guess, but the "send() and...

    Just a wild guess, but the "send() and recv()—Talk to me, baby!" section might have something to do with sending data to (and receiving data from) an IP address.
  12. Replies
    5
    Views
    349

    This sounds like an XY problem. What would you...

    This sounds like an XY problem. What would you need a 1-bit variable for?
  13. Thread: memcmp ?

    by christop
    Replies
    6
    Views
    381

    Casting (in this case, with (const void *)) is a...

    Casting (in this case, with (const void *)) is a way to tell the compiler that you know what you're doing. You don't know what you're doing (otherwise you wouldn't be asking us for help), so remove...
  14. Replies
    3
    Views
    324

    Do "Send" and "radioID" contain null-terminated...

    Do "Send" and "radioID" contain null-terminated strings? If not, string functions (e.g., strcpy) cannot be used on them. (The initializer for "Send" suggests that it's not a string and shouldn't be...
  15. Since you're doing XOR, you can drop one of the !...

    Since you're doing XOR, you can drop one of the ! on each side:


    bool isCrossing(float *pair)
    {
    return !signbit(pair[0]) ^ !signbit(pair[1]);
    }

    Or it might be faster to just do it this...
  16. Replies
    3
    Views
    352

    With a game like tic-tac-toe (or even one like...

    With a game like tic-tac-toe (or even one like chess), you only need to store the moves themselves as board locations (like (0,0)) in the undo stack, rather than a whole copy of the board. To undo a...
  17. Replies
    10
    Views
    601

    To be fair, getline is also defined by a standard...

    To be fair, getline is also defined by a standard extension to C as ISO/IEC TR 24731 (Dynamic Allocation Functions), though it's not part of the C standard itself.
  18. This isn't directly related to your problem, but...

    This isn't directly related to your problem, but you can replace this:



    typedef enum bool{ false = 0, true = 1 } bool;


    with this:
  19. Replies
    17
    Views
    1,158

    Not necessarily. size_t is a type that can hold...

    Not necessarily. size_t is a type that can hold the size of the largest supported object. For example, on ye olde x86 segmented memory system, size_t might be only 16 bits wide (no object can be...
  20. That might actually make the problem worse. The...

    That might actually make the problem worse. The expression ( (fahrenheit - 32) / 1.8 ) is already of type double, and casting it to float reduces its precision before the value is then converted to...
  21. Replies
    10
    Views
    672

    flp is right. The C standards make no guarantee...

    flp is right. The C standards make no guarantee that stdout will be flushed when the program reads from stdin, even if both point to the same terminal (and some implementations don't automatically...
  22. Replies
    213
    Views
    11,962

    ssize_t is part of the POSIX standard, not the C...

    ssize_t is part of the POSIX standard, not the C standard. And uchar.h is only in C11 and later (which MS doesn't support).
  23. How is myFlags declared? Is it shared with an...

    How is myFlags declared? Is it shared with an ISR? If it is, then it should be declared with volatile.
  24. strcmp doesn't return a "true" or "false" value....

    strcmp doesn't return a "true" or "false" value. It returns a value less than 0, 0, or a value greater than 0, depending on the relative order of the string arguments.

    You can think of it as...
  25. Replies
    20
    Views
    1,078

    I think what's partially responsible for the...

    I think what's partially responsible for the confusion is the incorrect and confusing documentation for UDP.read():



    I wasn't sure what that meant since the first argument, packetBuffer, holds...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4