Search:

Type: Posts; User: christop

Page 1 of 20 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    7
    Views
    334

    Don't they/them/their suffice? They've been...

    Don't they/them/their suffice? They've been acceptable as gender-neutral singular personal pronouns since, oh, the 14th century.
  2. What is your question? What do you need help...

    What is your question? What do you need help with?

    By the way, when I run your code it prints "10", as I would expect.
  3. Replies
    17
    Views
    296

    I wouldn't say it's ruled out. Undefined behavior...

    I wouldn't say it's ruled out. Undefined behavior can show up in any of the following ways:


    The program works as you expected.
    The program crashes.
    The program gives weird results.
    Demons...
  4. Replies
    17
    Views
    296

    That's likely because you used memcpy in an...

    That's likely because you used memcpy in an undefined way (e.g., source and destination overlap). I haven't looked too deeply at your code to see if that's the case, but there's an exceedingly low...
  5. Replies
    8
    Views
    266

    Each case creates two variables, leftweapon and...

    Each case creates two variables, leftweapon and rightweapon, and they both go out of scope outside the switch statement. Define them before the switch statement and only assign to them inside the...
  6. Replies
    7
    Views
    265

    It's not an issue of library version. It's how...

    It's not an issue of library version. It's how the C language works. It's bad to use feof() to control a loop because it's asking the wrong thing. feof() tells you that you have already tried to read...
  7. Replies
    7
    Views
    265

    That doesn't null-terminate the string. Also,...

    That doesn't null-terminate the string.

    Also, Why it's bad to use feof() to control a loop.
  8. Replies
    5
    Views
    340

    I wouldn't try to "sanitize" an SQL query. It's...

    I wouldn't try to "sanitize" an SQL query. It's much easier and foolproof to use prepared statements. See the documentation for how to use those.
  9. Replies
    7
    Views
    287

    But it has defined behavior. There's no ambiguity...

    But it has defined behavior. There's no ambiguity in ++*P++. It is equivalent to ++*(P++) because of operator precedence. It increments the object pointed to by P and then increments P (it's...
  10. Interesting. Have you seen any cases where using...

    Interesting. Have you seen any cases where using bool instead of int had a significant performance difference? I imagine most good compilers will treat a bool effectively the same as int in most...
  11. Replies
    7
    Views
    287

    Line 9 actually is not undefined behavior. ++*P++...

    Line 9 actually is not undefined behavior. ++*P++ increments both P and *P once each.
  12. What language is that? Ruby? I think you took a...

    What language is that? Ruby? I think you took a wrong turn somewhere while you were looking for a programming forum.
  13. Replies
    6
    Views
    449

    If you're going to put the whole command on a...

    If you're going to put the whole command on a single line, you need to leave out the backslash:


    gcc -O2 $(pkg-config --cflags glib-2.0) -o test test.c $(pkg-config --libs glib-2.0)

    A...
  14. Replies
    26
    Views
    1,161

    Try adding the value 0.999 to your test cases: ...

    Try adding the value 0.999 to your test cases:



    0.999000: 0, 100


    Oops!

    You need to round t (either with the round() function or by adding 0.005) before converting it to a integral and...
  15. Replies
    26
    Views
    1,161

    Well yes, of course, binary floating point cannot...

    Well yes, of course, binary floating point cannot accurately represent 0.3 (just like decimal cannot accurately represent 1/3, 0.3333...).

    My point was that if the double-precision approximation...
  16. Replies
    26
    Views
    1,161

    That's because you didn't properly round t when...

    That's because you didn't properly round t when computing i and f. What you ended up with is essentially floor(t * 100.0) / 100.0.
  17. Since mpz_t is already a pointer (otherwise...

    Since mpz_t is already a pointer (otherwise foo->_mp_size would not compile), shouldn't it be just ((mpz_t)ptrfoo)->_mp_size?
  18. Replies
    6
    Views
    559

    Reason 2 is a good enough reason to use "sizeof...

    Reason 2 is a good enough reason to use "sizeof (char)", but the standards actually guarantee/mandate that "sizeof (char) == 1".

    But my preferred way to write that code is like this:



    char...
  19. Thread: sizeof()

    by christop
    Replies
    7
    Views
    435

    sizeof gives you a compile-time constant value...

    sizeof gives you a compile-time constant value because the compiler knows how big all objects or types are at compile time. So if your code says "sizeof (int)", the compiler will effectively replace...
  20. Replies
    4
    Views
    302

    The constraints seem wrong because they exclude...

    The constraints seem wrong because they exclude the last index. Using the given example, it's not possible to pick "BBB" because that's at index 8 (M = 8), but M must be less than 8. The constraints...
  21. Replies
    9
    Views
    879

    Yes, that's a fair point. I think it's a pity...

    Yes, that's a fair point.

    I think it's a pity that there's no standard file positioning functions in C that takes/returns a 64-bit or longer integer type.
  22. Replies
    9
    Views
    879

    fgetpos and fsetpos take a pointer to fpos_t...

    fgetpos and fsetpos take a pointer to fpos_t (which should be a type that's large enough for a "large" file). These have been around since C89, so they're hardly platform-specific.

    There's also...
  23. Replies
    6
    Views
    365

    Merriam-Webster...

    Merriam-Webster says:


    So "DLL" is an acronym. (And an acronym is an abbreviation.)
  24. By the way, the main function returns int, not...

    By the way, the main function returns int, not void.
  25. Replies
    15
    Views
    1,203

    Haha, the S........horpe problem strikes again!...

    Haha, the S........horpe problem strikes again! (LOL, it's censored even when I Preview Post! That should be "S c u n t h o r p e".)
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4