Help!

This is a discussion on Help! within the C Programming forums, part of the General Programming Boards category; Quick, question, at the very end of my very last function, i do w = feof(filePtr1) and then while(w != ...

  1. #16
    Registered User
    Join Date
    Nov 2007
    Posts
    49
    Quick, question, at the very end of my very last function, i do

    w = feof(filePtr1)

    and then

    while(w != 0)

    but that dont work, what will feof return if its at the end of the file?

  2. #17
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    y is declared in fill_struct_integers but isnt initialized (set to anything). you do print it though, but it will likely have some random variable in it.

    edit:
    The function feof() tests the end-of-file indicator for the stream
    pointed to by stream, returning non-zero if it is set. The end-of-file
    indicator can only be cleared by the function clearerr().p
    i believe the FAQ has something about controlling loops using the check of EOF, check it out.
    Last edited by nadroj; 12-03-2007 at 07:52 PM.

  3. #18
    Registered User
    Join Date
    Nov 2007
    Posts
    49
    Ty, i just realised that I used it right before in the same program..., i think i need a nap...
    My teacher thougt me it that way, im sorry...
    That and fflush(stdin)....
    Last edited by Tyrant; 12-03-2007 at 08:00 PM.

  4. #19
    Registered User
    Join Date
    Nov 2007
    Posts
    49
    I got it, I'ill stop reading the file exactly before the end of file...
    Nice.... it works....
    Last edited by Tyrant; 12-03-2007 at 08:28 PM.

  5. #20
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    As to the original question: In standard C prior to C99, you can't declare variables in places other than beginning of a block [that means, the variables must be before any "code" within the particular set of braces].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21