Search:

Type: Posts; User: christop

Page 1 of 20 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    20
    Views
    500

    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...
  2. Replies
    20
    Views
    500

    Is this for Arduino? In that case, Udp.read()...

    Is this for Arduino? In that case, Udp.read() returns the number of bytes read, not the data itself. You will have to parse the packet data in the packetBuffer variable after you read it from UDP.
  3. Ah! So you do: case 's': if (ofstream...

    Ah! So you do:



    case 's':
    if (ofstream output_file{filename}) {
    .... some code ....
    }
    break;
    case 'x':
  4. I would even rewrite it to something like this...

    I would even rewrite it to something like this which also limits the scope of output_file:



    case 's':
    if (ofstream output_file(filename)) {
    .... some code ....
    }
    break;...
  5. The output_file variable is still in scope at...

    The output_file variable is still in scope at case 'x', but since the variable wouldn't be properly initialized if case 'x' is taken, the compiler complains about that. A simple fix is to put braces...
  6. You're already linking to libc, right? Then you...

    You're already linking to libc, right? Then you have all of the string functions.



    Sure, it can be useful as an academic exercise, but (IMO) it's pointless if you just want to write an...
  7. unknown_072: Your code in #11 still uses "+" for...

    unknown_072: Your code in #11 still uses "+" for string concatenation. That does not work as laserlight mentioned in post #2. That needs to be fixed.

    Structure: There's no need to reinvent the...
  8. Replies
    5
    Views
    409

    Modifying a string literal is undefined behavior....

    Modifying a string literal is undefined behavior. See STR30-C. Do not attempt to modify string literals. (If a pointer to char points to a string literal, it's a good idea to declare it as const to...
  9. Replies
    13
    Views
    2,600

    How would a map like that have, for example, a...

    How would a map like that have, for example, a room at (1,2) with an exit to the south that leads to the room at (7,8)? How would it name each room or list the inventory in each room?
  10. Wow! Did you manage to write a kernel with...

    Wow! Did you manage to write a kernel with multitasking, multi-user, networking, portable to dozens of architectures, with support for thousands of device drivers and which can scale down to a...
  11. The 2038 problem is already fixed on 64-bit...

    The 2038 problem is already fixed on 64-bit arches on Linux (time_t is a 64-bit integer), and I believe it's been fixed on 32-bit arches recently too. The problem might still exist in some userland...
  12. Replies
    28
    Views
    1,116

    Try compiling this code: if ((char)-1 < 0)...

    Try compiling this code:



    if ((char)-1 < 0) {
    puts("char is signed");
    } else {
    puts("char is unsigned");
    }
  13. Replies
    28
    Views
    1,116

    You can do the same thing in the compiler, which...

    You can do the same thing in the compiler, which is (IMO) cleaner than using the preprocessor:



    if (CHAR_SIGNED) {
    alu_puts("CHAR_SIGNED");
    } else if (CHAR_UNSIGNED) {
    ...
  14. Replies
    28
    Views
    1,116

    Here's a problem: #ifndef CHAR_SIGNED #...

    Here's a problem:



    #ifndef CHAR_SIGNED
    # if defined( __CHAR_UNSIGNED__ )
    # elif defined( __CHAR_SIGNED__ )
    # define CHAR_SIGNED
    # elif ('\0'|(1 << (CHAR_BIT-1))) < 0
    # define CHAR_SIGNED
  15. Replies
    7
    Views
    412

    Maybe awsdert is trying to write code that will...

    Maybe awsdert is trying to write code that will work in a language that is similar to but not exactly C? (If the language doesn't have all of the definitions then it's not actually C, or it's a very...
  16. Replies
    5
    Views
    639

    No need to reinvent the Boolean wheel. Use bool...

    No need to reinvent the Boolean wheel. Use bool from stdbool.h instead. It's been a standard part of C for over 20 years now.
  17. Replies
    10
    Views
    661

    Yes, I know. I just wanted to point out one...

    Yes, I know. I just wanted to point out one problem that's caused by storing the return value of getchar() in a char instead of int.

    Another problem is that, on platforms where char is signed (so...
  18. Replies
    3
    Views
    482

    Change them to uint8_t and add #include...

    Change them to uint8_t and add #include <stdint.h> to the top of the source file (that's from C99 which has been around for over 20 years now).
  19. Replies
    10
    Views
    661

    Also, getchar() returns an int, not char, so...

    Also, getchar() returns an int, not char, so decide should be an int, not char. (On some platforms, char is unsigned, so it can't ever be equal to EOF. Plus, it's easier to do the correct thing--you...
  20. Replies
    8
    Views
    744

    Why is it a picture? If it's a picture then you...

    Why is it a picture? If it's a picture then you can't even build and run it, so the first step would be to turn it into a source code file that a compiler can understand.
  21. What is the exact error message? Copy and paste...

    What is the exact error message? Copy and paste it here; don't type it out.
  22. There is a bad interaction happening between...

    There is a bad interaction happening between stdio and the low-level select file operation. getchar() (and stdio in general) works by reading a chunk of data at a time into an internal buffer and...
  23. Replies
    6
    Views
    647

    Ah, I think Malcolm hit the nail on the head. I...

    Ah, I think Malcolm hit the nail on the head. I overlooked that it's an array. It's an array so it "decays" to a pointer to the first element of the array, and since it's the first field in the...
  24. Replies
    6
    Views
    647

    Since this is undefined behavior, the compiler...

    Since this is undefined behavior, the compiler can do anything it wants to do, even including printing "(null)".
  25. Replies
    8
    Views
    625

    This may or may not be related to your problem,...

    This may or may not be related to your problem, but what is the value of "a" at this line: while (a<10){? Hint: you don't know.
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4