doubt in EOF

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rampraveen
    New Member
    • Apr 2010
    • 37

    doubt in EOF

    while((c=getc(f in))!=EOF)..... .. any body knows what is the work of EOF here....i saw EOF value is equal to 0 and -1...but i do't know how it works here .....if anybody knows pls tell...End Of File means whether it reads the given file upto the last line of a file..pls help me........
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    No normally EOF has a value of -1 because the characters read have values in the range 0 - 255.

    This basically keeps reading characters from the file until the end of the file is reached.

    It is important that c has the type int, it will not work properly if c is a char.

    Comment

    Working...