Search:

Type: Posts; User: Hodor

Page 1 of 20 1 2 3 4

Search: Search took 0.01 seconds.

  1. If you don't mind losing the original values in...

    If you don't mind losing the original values in the array and there is a value that can be considered invalid then a third option is to "cross out" already counted values in the array after you've...
  2. Replies
    12
    Views
    335

    The first thing I'd do is try and narrow down...

    The first thing I'd do is try and narrow down where the bug(s) might be. For example, leave out the edge detection and see if the grey image is written properly. To do this, make line 81 (currently...
  3. Replies
    12
    Views
    335

    At a glance, you're not calculating the offsets...

    At a glance, you're not calculating the offsets into your array correctly... [x*y] isn't correct... it would normally be something like [x + y * width]

    Check lines 68-70 and 164-166. Also check...
  4. Perhaps the problem is that int...

    Perhaps the problem is that


    int array2={5,1,2,3,4,5};



    is not an array
  5. It's quite difficult to keep track of things in...

    It's quite difficult to keep track of things in my head because of the global variables. There's no reason for the global variables and I think it'd be worthwhile rewriting things to get rid of those...
  6. I made an edit while you were replying. Your way...

    I made an edit while you were replying. Your way in this new post is fine as well, of course
  7. When your code reaches line 96, what is the value...

    When your code reaches line 96, what is the value of current->record_list? As far as I can see it's NULL, because program execution only reaches line 96 if current->record_list is NULL (see line 89;...
  8. current->record_list is NULL on line 96, as...

    current->record_list is NULL on line 96, as proven by line 89, and then you're trying to dereference (i.e. you're effectively trying to do NULL->c_detail1) so it crashes.

    On line 95, where is...
  9. Replies
    11
    Views
    509

    Also, you may want to turn on your compiler...

    Also, you may want to turn on your compiler warnings and check what type fopen() returns as well as making sure that it's not NULL
  10. Replies
    13
    Views
    369

    Thanks. For completeness (to cover the case of...

    Thanks.

    For completeness (to cover the case of argc == 0 amongst other things)



    So argv[0] might be a NULL pointer if argc == 0 and might be an empty string if argc > 0 (argv[0][0] == '\0')....
  11. Replies
    13
    Views
    369

    I concede that if you run the program on a modern...

    I concede that if you run the program on a modern desktop OS then, yes, it's very unlikely that argc will be 0, but the C standard allows for it to be 0 (and if it's 0 then argv[0] will be NULL)....
  12. Replies
    13
    Views
    369

    On a tangent and just out of interest, given: ...

    On a tangent and just out of interest, given:


    int main (int argc, char *argv[])

    {
    // Get program name for error reporting.

    strcpy(program_name, basename(argv[0]));
  13. Replies
    6
    Views
    302

    What is a "struct call"?

    What is a "struct call"?
  14. Replies
    11
    Views
    323

    ^ this. I think it's also important to note that...

    ^ this. I think it's also important to note that if you compile with optimisation (-O1, -O2 etc, including -Os) gcc doesn't store the string as immediate data. E.g. given:


    #include <stdio.h>
    ...
  15. Replies
    11
    Views
    323

    Thanks for pointing this out. I was of course...

    Thanks for pointing this out. I was of course being deliberately sloppy to make my point but I should have made that clearer in my post. I rarely see somebody write char *str = "Hello"; (i.e. without...
  16. Replies
    11
    Views
    323

    Forget that char *str = "Hello"; /*...

    Forget that



    char *str = "Hello"; /* example 1 */ /*should really be const char *str because modifying the values it points to is naughty */


    is very different to
  17. Thread: School Record

    by Hodor
    Replies
    6
    Views
    348

    I don't know why you'd even try this. Use a...

    I don't know why you'd even try this. Use a database, not C
  18. Thread: HW

    by Hodor
    Replies
    2
    Views
    207

    Why don't you compile it and see? Actually it...

    Why don't you compile it and see?

    Actually it won't display anything at all because the use of "smart" quotes and a missing semicolon means that it won't compile.
  19. Thread: HW

    by Hodor
    Replies
    2
    Views
    246

    Despite this not being a homework service, the...

    Despite this not being a homework service, the question is dumb because two of the answers are correct (assuming you introduced the "smart" ' characters instead of simple ')
  20. Replies
    5
    Views
    461

    The C11 standard would disagree and what gcc does...

    The C11 standard would disagree and what gcc does is immaterial.

    For functions other than main(void) gcc on my system does produce different ASM for fn() and fn(void)

    Edit:



    Therefore...
  21. I wouldn't worry about your age. 25 is pretty...

    I wouldn't worry about your age. 25 is pretty young. I don't know what uni/college is like where you are but here in Australia there are lots of people older than 25 attending even at undergraduate...
  22. Replies
    4
    Views
    327

    The K&R approach is pretty bad, but using conio.h...

    The K&R approach is pretty bad, but using conio.h is arguably worse. At least, as bad as it is, the K&R approach is portable. Try compiling your solution using conio.h using anything but Windows or...
  23. Replies
    4
    Views
    327

    Your printf() is wrong as well. Change to: ...

    Your printf() is wrong as well. Change to:



    printf ("%d\n", *pn);

    return c;

    }
  24. Replies
    4
    Views
    327

    Have you implemented getch() and ungetch()? ...

    Have you implemented getch() and ungetch()?


    Edit: the functions are also provided at the bottom of the first post in this thread: Complex declarations &amp; ?error in Kernighan/Ritchie?
  25. Replies
    10
    Views
    532

    It was late at night and I was merely quoting....

    It was late at night and I was merely quoting. What I meant to write is that int function() is not the same as int function(void) in the current and previous version of the standard.
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4