Search:

Type: Posts; User: cwr

Page 1 of 20 1 2 3 4

Search: Search took 0.01 seconds.

  1. Thread: Signal handling

    by cwr
    Replies
    2
    Views
    600

    execvp replaces the current process with the new...

    execvp replaces the current process with the new one, so your program "stops executing" as soon as you call execvp. You need to call fork() first to make a new process.
  2. Replies
    3
    Views
    1,743

    I believe your only choice is to change the...

    I believe your only choice is to change the typedef or create a new typedef or not use it:


    typedef const int *ptr;
    ptr p;
  3. Replies
    25
    Views
    2,244

    Okay, so you've managed to create a loop, but...

    Okay, so you've managed to create a loop, but it's not much use because it insists on reading exactly 5 characters from the file. What you want is a loop that continues until you read the end of the...
  4. Replies
    15
    Views
    12,290

    Plenty of languages other than C support...

    Plenty of languages other than C support arbitrary precision arithmetic natively, and project euler doesn't require the use of C. If you need/want to use C and don't have C99 long long support (you...
  5. Replies
    25
    Views
    2,244

    Great, where's what you've got so far? No. ...

    Great, where's what you've got so far?


    No.



    Looks like homework. Show an attempt first. You might use fgetc which reads characters or fgets which reads lines (provided the buffer is big...
  6. Replies
    6
    Views
    1,257

    You are correct that it's casting it to a pointer...

    You are correct that it's casting it to a pointer to struct sockaddr, but C does not have "pass by reference". You are passing a pointer to sin.
  7. Replies
    3
    Views
    1,029

    I can't think of any easy (or practically...

    I can't think of any easy (or practically feasible way). This is why most programs that allow third party plugins invent their own domain specific language and just parse that themselves, instead of...
  8. Replies
    15
    Views
    2,056

    You've presumably not worked with gcc then? It...

    You've presumably not worked with gcc then? It will show this with -W or -Wextra.
  9. Replies
    7
    Views
    1,585

    This is undefined behaviour, as is the original...

    This is undefined behaviour, as is the original poster's code. You may only use a character pointer. If you have the ISO/IEC 9899:1999 standard handy, see section 6.3.2.3 paragraph 7.

    The...
  10. Thread: Timing program

    by cwr
    Replies
    7
    Views
    1,213

    No, malloc() does not initialise the space it...

    No, malloc() does not initialise the space it allocates, as already said by Salem.
  11. Replies
    24
    Views
    2,138

    Only if you count variations on the above, such...

    Only if you count variations on the above, such as making the first element of the array the length.

    When you use int a[] in the parameter list of a function declaration it's equivalent to int *a;...
  12. Replies
    13
    Views
    1,265

    Yes, there's no standard way, as Salem already...

    Yes, there's no standard way, as Salem already said.
  13. Replies
    13
    Views
    1,265

    See also http://c-faq.com/osdep/cbreak.html

    See also http://c-faq.com/osdep/cbreak.html
  14. Thread: Fibbonacci Code

    by cwr
    Replies
    18
    Views
    2,464

    Actually 48 :p 0, 1, 1, 2, 3, 5, 8, 13, 21,...

    Actually 48 :p

    0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040, 1346269,...
  15. Replies
    5
    Views
    1,327

    I said %f was float. A double is not the same as...

    I said %f was float. A double is not the same as a float.

    In scanf, use %lf for a double, and %f for a float.

    In printf, use %f for both. It's inconsistent, but there's a reason for it.
  16. Replies
    5
    Views
    1,327

    You are trying to pass a float (%f) into an int...

    You are trying to pass a float (%f) into an int (input), you don't want to do this.

    Other than that, at first glance, your array filling function appears to be reasonable. The code calling...
  17. Replies
    19
    Views
    3,829

    getline() is not a standard C function, fgets()...

    getline() is not a standard C function, fgets() is, and is the preferred alternative to gets(). The problem with gets() has nothing to do with "flushing the buffer", and is wholly to do with not...
  18. Thread: free()

    by cwr
    Replies
    10
    Views
    1,379

    memset just sets bytes of memory to a specifieed...

    memset just sets bytes of memory to a specifieed value, it has nothing to do with memory allocation.

    If you are using malloc(), the only thing you want to use to free it, is free().

    By the way,...
  19. I'm guessing m/c is microcontroller. Look at...

    I'm guessing m/c is microcontroller. Look at /proc/cpuinfo to see if there's a processor difference?
  20. Replies
    7
    Views
    1,090

    It's allowed in C99.

    It's allowed in C99.
  21. Replies
    8
    Views
    1,684

    If your array type is int, then memset over the...

    If your array type is int, then memset over the entire thing should be safe:


    memset(array, 123, sizeof(array));

    If it's not an int, then individual assignment will be required, as you...
  22. Replies
    4
    Views
    27,050

    You don't really need the convoluted arithmetic:...

    You don't really need the convoluted arithmetic:

    /* prints "3" */
    printf("%.0f", 3.14159265);
    /* prints "4" */
    printf("%.0f", 3.6);

    /* prints "3.14" */
    printf("%.2f", 3.14159265358979);
  23. Replies
    7
    Views
    1,654

    http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?a...

    http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1043803465&id=1043284385
  24. Replies
    4
    Views
    27,050

    Well for a start trunc takes a double and returns...

    Well for a start trunc takes a double and returns a double, and you're playing with ints.

    Secondly, i is an int (integer), so it can't store a value of 5.156546 (not an integer).
  25. Replies
    7
    Views
    1,797

    Please show a minimal test case that we can see...

    Please show a minimal test case that we can see your code and run it.
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4