Search:

Type: Posts; User: cas

Page 1 of 20 1 2 3 4

Search: Search took 0.03 seconds.

  1. Replies
    13
    Views
    11,633

    Either precision in the language matters or it...

    Either precision in the language matters or it doesn't.
  2. Replies
    13
    Views
    11,633

    Maybe at this point it should be noted that...

    Maybe at this point it should be noted that offsetof is neither a keyword nor a function, but a macro.
  3. Replies
    10
    Views
    2,081

    In general when the program exits, all memory...

    In general when the program exits, all memory will be reclaimed by the OS, so it's typically not something you need to worry about. That said, it's not bad practice to do so, and if this were a...
  4. Thread: const pointers

    by cas
    Replies
    10
    Views
    3,723

    Because C does not prevent you from doing...

    Because C does not prevent you from doing incorrect things, or at least doesn't make it hard to do incorrect things. The warning is correct and required: if you assign a const pointer to a non-const...
  5. Replies
    13
    Views
    5,777

    In main(), you need to assign a value to charCtr,...

    In main(), you need to assign a value to charCtr, since initially it will contain garbage.

    By calling srand() in calcCollisionPayload(), assuming that time() returns the time in seconds, you will...
  6. Given that the linker is providing prototypes...

    Given that the linker is providing prototypes (i.e. it's including parameter types), I'm inclined to think you're building with a C++ compiler, which encodes that information. Had you built with a C...
  7. Replies
    10
    Views
    2,434

    In a POSIX environment, system() just passes the...

    In a POSIX environment, system() just passes the string to /bin/sh, so you still have to worry about shell issues (what if the image name has a space in it, for example?).

    If you want to safely...
  8. Replies
    2
    Views
    2,320

    First, it's probably a bad idea to name a header...

    First, it's probably a bad idea to name a header “math.h”, since that's a standard header name. You're already accidentally including the wrong header in runner.c when you use <> instead of "" to...
  9. Replies
    9
    Views
    3,525

    You're not giving “i” a value, so it's filled...

    You're not giving “i” a value, so it's filled with garbage. A good modern compiler (e.g. gcc or clang) can warn about this:



    t.c: In function 'recursiveLinearSearch':
    t.c:50:1: warning:...
  10. Thread: do-while loop

    by cas
    Replies
    3
    Views
    721

    That condition is always true (if it's 'C' it's...

    That condition is always true (if it's 'C' it's not 'c', and if it's 'c' it's not 'C'). You probably want &&.

    Note: “this is not working” is not a good error report. You neglected to mention...
  11. userName[i] != '\n' || userName[i] != '\0'; ...

    userName[i] != '\n' || userName[i] != '\0';

    This will always evaluate to true. You want to use && instead of ||.



    !isblank(userName[i]) || userName[i] != '\n'

    Same here. Plus you're not...
  12. Replies
    16
    Views
    4,005

    Given two types T1 and T2, compilers are required...

    Given two types T1 and T2, compilers are required to issue diagnostics (i.e. warning/error messages) if you assign T1* to T2* if T1 and T2 are not compatible types. Without going into smaller...
  13. Replies
    5
    Views
    4,909

    res->ai_addr has type struct sockaddr * (i.e....

    res->ai_addr has type struct sockaddr * (i.e. pointer to struct sockaddr).

    You know that it is really pointing to a struct sockaddr_in *, because res->ai_family tells you so.

    So you're not...
  14. Replies
    1
    Views
    758

    Once you've returned from the function that calls...

    Once you've returned from the function that calls setjmp(), you can no longer jump to it; setjmp() relies on you to keep the function alive for a call from longjmp(). In a sense, setjmp() just...
  15. Replies
    5
    Views
    4,909

    First, #include , which is needed...

    First, #include <arpa/inet.h>, which is needed for inet_ntop().

    You need to treat the struct sockaddr as the proper type, by casting it. Example:


    inet_ntop(res->ai_family, &((struct...
  16. Thread: fputc problem

    by cas
    Replies
    2
    Views
    951

    This: while(c=fgetc(fp)!=EOF) Is...

    This:


    while(c=fgetc(fp)!=EOF)

    Is equivalent to:


    while(c=(fgetc(fp)!=EOF))
  17. That'd be quite compiler/system dependent. ...

    That'd be quite compiler/system dependent. Possibly your compiler inserts padding so that you're scribbling on unused memory for a few elements, before you start writing to critical areas.

    Add...
  18. int SIZE = 0; int array[SIZE]; This is...

    int SIZE = 0;
    int array[SIZE];

    This is undefined behavior. You cannot have a zero-sized array. Even if you change the value of SIZE later, the array will not change to reflect that. The quick...
  19. Replies
    13
    Views
    5,320

    Use "bt" (backtrace) to find out where, in your...

    Use "bt" (backtrace) to find out where, in your code, the problem happened.

    It looks like you're passing an invalid value to scanf() (or related function), though. Hard to say without seeing code.
  20. Replies
    1
    Views
    810

    Nope, can't be done. You could probably cover...

    Nope, can't be done.

    You could probably cover most cases by using CUPS for the Unix side (including OS X) and whatever Windows does for the Windows side. That shouldn't be too onerous.
  21. Replies
    4
    Views
    2,150

    The condition in line 29 (i < n) is wrong;...

    The condition in line 29 (i < n) is wrong; neither i nor n changes in the loop, so the result will always be the same. Presumably you meant to use "k", not "i".
  22. Replies
    3
    Views
    701

    Your compiler has to be warning you about an...

    Your compiler has to be warning you about an invalid call to ArrayScan() (if it's not, it's broken, and you should get a new compiler).

    You're passing &array to ArrayScan(). array has type int*,...
  23. Replies
    3
    Views
    1,024

    Then you're either using a C++ compiler or a...

    Then you're either using a C++ compiler or a terrible C compiler. I'd guess the former. If you're learning C, configure your compiler to be a C compiler not C++ (it might be as easy as naming the...
  24. Replies
    3
    Views
    1,024

    A few things. *(c+x) can be written c[x],...

    A few things.

    *(c+x) can be written c[x], which tends to be easier to read.

    getchar() does not return '\0' to mean “end of input”. Rather, it returns EOF; if you want to stop when the user...
  25. Replies
    8
    Views
    1,981

    atoi() is undefined if the result does not fit...

    atoi() is undefined if the result does not fit into an int; lots of systems will reduce it modulo 2**32, but that's not a requirement. Also, int need not be 32 bits wide (it could be smaller or...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4