News:

Build a stunning handcrafted website with IT Acumens

Main Menu

Defenition of EOF

Started by thiruvasagamani, Jul 28, 2008, 02:14 PM

Previous topic - Next topic

thiruvasagamani



The EOF seems to cause a lot of confusion with some new coders, hopefully this explanation will help you understand better. Before I go into too much detail about what EOF is, I'll tell you what it isn't.

EOF is NOT:

A char

A value that exists at the end of a file

A value that could exist in the middle of a file

And now to what it actually is.

EOF is a macro defined as an int with a negative value. It is normally returned by functions that perform read operations to denote either an error or end of input. Due to variable promotion rules , it is important to ensure you use an int to store the return code from these functions, even if the function appears to be returning a char, such as getchar() or fgetc().
Thiruvasakamani Karnan