Search:

Type: Posts; User: Memloop

Page 1 of 17 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    3
    Views
    3,231

    Repeated calls to realloc causes segfault

    Repeated calls to bitstream_add_bit will eventually cause a segfault. A backtrace revealed that it was realloc that crashed. I've looked at the most common mistakes involving realloc but I can't find...
  2. Thread: Buffer

    by Memloop
    Replies
    3
    Views
    789

    Circular buffer - Wikipedia, the free...

    Circular buffer - Wikipedia, the free encyclopedia
  3. The symbols must be present in your console's...

    The symbols must be present in your console's current character set. What character set did you find them in? Try changing the character set of the console to the one that has the desired characters.
  4. Replies
    13
    Views
    7,961

    if (1 && 0) puts("True"); else ...

    if (1 && 0)
    puts("True");
    else
    puts("False");



    if (1 || 0)
    puts("True");
    else
  5. Replies
    13
    Views
    7,961

    Convert T to 1 and F to 0. Then use the logical...

    Convert T to 1 and F to 0. Then use the logical operators in C. For example:

    T O T => 1 || 1
  6. Replies
    6
    Views
    2,920

    Not sure what kind of game you had in mind, but...

    Not sure what kind of game you had in mind, but here as some good articles to read: Game Development Tutorials – Networking for Game Programmers
  7. I think it's a good idea to put the interface...

    I think it's a good idea to put the interface first so that other developers can quickly find what they need. In other words, what Elysia wrote.
  8. Replies
    1
    Views
    1,108

    The way you've done it is fine, but you need to...

    The way you've done it is fine, but you need to be a bit careful so that the result doesn't overflow (signed overflow is undefined). This typically involves making sure that you're not negating...
  9. Replies
    20
    Views
    3,313

    The point is that you can use void main and still...

    The point is that you can use void main and still be compliant if you're using a freestanding implementation that supports it. You're not even required to have a main function to begin with if your...
  10. Replies
    20
    Views
    3,313

    When discussing this, you need to distinguish...

    When discussing this, you need to distinguish between a hosted and freestanding implementation. Freestanding implementations have much more freedom in how the program's entry point is specified.
  11. scanf, sscanf etc are not suited for numeric...

    scanf, sscanf etc are not suited for numeric input validation since they do not detect overflows.

    Read in the number as a string and use strtol/strtoul to convert the input to a long integer, and...
  12. Replies
    15
    Views
    1,356

    You will need to work with dynamic memory if the...

    You will need to work with dynamic memory if the number of students is unknown at compile time. This basically means replacing all fixed size arrays with dynamically allocated arrays once you know...
  13. Replies
    14
    Views
    1,878

    Use a double and accept some loss of precision,...

    Use a double and accept some loss of precision, or use a bignum library like GMP: The GNU MP Bignum Library
  14. Replies
    11
    Views
    1,316

    > One more question is how to convert an integer...

    > One more question is how to convert an integer n to an unint64_t array of 8 elements.

    That doesn't make any sense, and you still have the same problems with portability as I described above....
  15. Replies
    11
    Views
    1,316

    A char is a byte in C per definition (but it does...

    A char is a byte in C per definition (but it does not need to have 8 bits). uint64_t is exactly 64 bits on platforms where such a type can be implemented. Because of that, your solution is not...
  16. Thread: Help me coding

    by Memloop
    Replies
    4
    Views
    920

    Put the if expression inside the while loop and...

    Put the if expression inside the while loop and only print i when the expression is true. Or you could simply start at i=2 and increment it with two instead of one each iteration.
  17. Thread: Help me coding

    by Memloop
    Replies
    4
    Views
    920

    Use code tags when posting code. To see if a...

    Use code tags when posting code.

    To see if a number is even, you can use the modulus operator:

    if (i % 2 == 0)
    {
    /* i is even. */
    }
  18. >first of all, how come you can do this in C++...

    >first of all, how come you can do this in C++ and not in C
    >
    >int a[n];

    The feature you're using there is actually a C99 feature that's not available in C++ unless you use non-standard...
  19. This can easily be generalized to an entire...

    This can easily be generalized to an entire string:

    uint8_t text[] = "Hello";
    uint8_t i;
    uint8_t *p = &text[0];

    /* Transmit the first character. */
    for (i = 0; i < 8; ++i)
    {
    /* Wait...
  20. Replies
    3
    Views
    4,807

    If you also have the array, you can pass that to...

    If you also have the array, you can pass that to the vector constructor so that the vector gets initialized with the values in the array.

    vector<int> list(list_array, list_array +...
  21. Replies
    2
    Views
    41,671

    What did you expect? There's a difference between...

    What did you expect? There's a difference between the integer value 10 and its textual representation in ASCII. Use fprintf with the %d specifier if you want the integer to written as ASCII text.
  22. Replies
    8
    Views
    2,927

    scanf doesn't check for numeric overflow, so it's...

    scanf doesn't check for numeric overflow, so it's inherently unsuited for getting numeric input.

    The best way to get numeric input is to read it in as a string first with fgets or similar, and...
  23. Replies
    1
    Views
    1,129

    Read one line at a time and use strchr to locate...

    Read one line at a time and use strchr to locate the desired delimiter character. This means you will need pointers to the beginning of the string and to every occurrence of the delimiter character....
  24. Replies
    3
    Views
    1,468

    The WebKit Open Source Project...

    The WebKit Open Source Project
  25. Replies
    2
    Views
    1,313

    There is some discussion on the matter here: C++...

    There is some discussion on the matter here: C++ Standard Library Active Issues List

    It seems that failbit gets set on numeric overflow, but there's no way to explicitly check for overflows.
Results 1 to 25 of 404
Page 1 of 17 1 2 3 4