Search:

Type: Posts; User: john.c

Page 1 of 20 1 2 3 4

Search: Search took 0.01 seconds.

  1. Maybe you are supposed to ignore a bit that...

    Maybe you are supposed to ignore a bit that overflows (at least under certain conditions). Then the answer is 1, as expected.
  2. Replies
    1
    Views
    171

    Presumably your first example is supposed to call...

    Presumably your first example is supposed to call foo1 and your second is supposed to call foo2 (with a properly defined s).

    The postfix increment operator has higher precedence than the...
  3. Assuming they are all supposed to be transformed...

    Assuming they are all supposed to be transformed into some kind of 2-d array, here are some possibilities.



    #include <stdio.h>
    #include <stdlib.h>
    #include <time.h>

    // For allocation of...
  4. Replies
    3
    Views
    211

    okay

    okay
  5. Replies
    3
    Views
    211

    pmatrix needs to be a triple pointer to be able...

    pmatrix needs to be a triple pointer to be able to set it to NULL in the caller.


    void freeMatrix(pixel *** pmatrix, size_t rows){
    for (int i = 0; i < rows; ++i)
    ...
  6. In the future, remember that it is best to post a...

    In the future, remember that it is best to post a complete program (headers,main,etc) so that we can easily run (or try to compile) it.

    The compiler does not know how to set a Planet to a char....
  7. Replies
    10
    Views
    378

    That's not the actual reason getchar returns an...

    That's not the actual reason getchar returns an int. The reason is so that EOF can be chosen to be a bit pattern that can never occur in a char (an "out-of-band" value). Obviously that means it must...
  8. Thread: Using modf()

    by john.c
    Replies
    2
    Views
    730

    #include #include int...

    #include <iostream>
    #include <cmath>

    int main() {
    float value = 123.456;
    float whole, part = std::modf(value, &whole);
    std::cout << value << '\n' << whole << '\n' << part << '\n';...
  9. Replies
    6
    Views
    315

    @christop, Obviously it's undefined behavior....

    @christop, Obviously it's undefined behavior. That's not the point. And I have no problem with printf printing "(null)". The point is how does the printf get called at all? Why doesn't it blow up as...
  10. Replies
    6
    Views
    315

    Dereferencing mystery?

    I find it strange that NULL is passed to printf below. Since p is NULL, it seems more likely that p->s would blow up before the function call.


    #include <stdio.h>

    typedef struct {
    char...
  11. Replies
    10
    Views
    786

    Your input file is text, not binary. If you need...

    Your input file is text, not binary.
    If you need your output to be binary, what exactly is the format?
    I've output to a text file below, one integer per line.
    Never say ios::in for an ifstream or...
  12. Replies
    8
    Views
    409

    ` 2 3 5 ...

    ` 2 3 5 7 11 13 17 19 23 29 31 37 41
    1: 1 1
    2: 2 2 1
    3: 4 ...
  13. Replies
    8
    Views
    409

    ` Prime Factors Ord ...

    ` Prime Factors
    Ord Value Divs 2 3 5 7 11 13 17 19
    1: 1 1
    2: 2 2 1
    3: 4 3 2
    4: 6 4 1...
  14. Replies
    8
    Views
    346

    You don't know what you're talking about. It...

    You don't know what you're talking about.
    It makes perfect sense.
    Of course it should be "allowed".
  15. Replies
    4
    Views
    259

    65525, actually, but yes, wraparound is...

    65525, actually, but yes, wraparound is well-defined with unsigned values.


    #include <stdio.h>
    #include <stdint.h>

    int main()
    {
    uint16_t n = (uint16_t)(-1); // -1 interpreted as...
  16. As usual, I don't understand what you are trying...

    As usual, I don't understand what you are trying to do. The code doesn't make sense to me and you've never really been able to explain what in the world you are trying to do overall. I'm lost. It's...
  17. I didn't test it and forgot some closing...

    I didn't test it and forgot some closing double-quotes.
    But you put them in the wrong place.
    Note that you should probably use _pclose to close a FILE* opened with _popen.


    FILE* dns =...
  18. It may have been overly-complicated (showing two...

    It may have been overly-complicated (showing two different ways and using inttypes).
    How about this.


    #include <stdio.h>
    #include <string.h>

    int main()
    {
    FILE *in = fopen("input.txt",...
  19. #include #include #include...

    #include <stdio.h>
    #include <string.h>
    #include <inttypes.h>

    #define FRM_SCN "%" SCNu32 ".%" SCNu32 ".%" SCNu32 ".%" SCNu32
    #define FRM_PRI "%" PRIu32 ".%" PRIu32 ".%" PRIu32 ".%" PRIu32
    ...
  20. I didn't realize that the input was restricted to...

    I didn't realize that the input was restricted to 0 to 10.
    In that case it will sort of work, but it's an incredibly stupid idea.
  21. You really need to improve your spacing. You...

    You really need to improve your spacing.

    You seem to be trying to return the fib through the program's exit status.
    That's not going to work.


    #include <stdio.h>
    #include <stdlib.h>...
  22. Replies
    5
    Views
    195

    I wouldn't put it quite like that. But if a...

    I wouldn't put it quite like that.
    But if a calculation can be done at compile time then that's when it will usually be done (at least with optimizations).
    So if you say printf("%d\n", 2 * 3 * 4)...
  23. The return value from main is different from...

    The return value from main is different from return values from other functions.
    Main's return value is called the program's "exit status".
    It is non-portable to use this value for anything but...
  24. Replies
    5
    Views
    195

    There should be no difference in this case since...

    There should be no difference in this case since 'sizeof(struct _menu_item)' is constant, so nothing needs to be "calculated" at run-time since it's done at compile time.
  25. So what should we enter for "size" and...

    So what should we enter for "size" and "seconds"???

    And look at lines 168 and 169 above.
    Array indices start at 0, and the max index for a 3-element array is 2.
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4