EOF
is NOT:
EOF
is NOT:
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 (discussed in detail later), 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()
.What is this value? EOF A common misconception of students is that files have a special EOF character at the end. There is no special character stored at the end of a file. EOF is an integer error code returned by a function. WHEN THRE IS NOTHING REMAINING TO READ ..
In computing, End Of File (commonly abbreviated EOF) is a condition in a computer operating system where no more data can be read from a data source. The data source is usually called a file or stream. In general, the EOF is either determined when the reader returns null as seen in Java's BufferedReader,or sometimes people will manually insert an EOF character of their choosing to signal when the file has ended.
In the C Standard Library, the character reading functions such as getchar return a value equal to the symbolic value (macro)
EOF
to indicate that an end-of-file condition has occurred. The actual value of EOF
is system-dependent (but is commonly -1, such as in glibc[3]) and is unequal to any valid character code. Block-reading functions return the number of bytes read, and if this is fewer than asked for, then the end of file was reached.
No comments:
Post a Comment