Syntax
#include <io.h> int __eof (int handle);Description
Value
This example creates the file sample.dat and then checks if the file pointer is at the end of that file using the __eof function.
#include <sys\stat.h>#include <io.h>
#include <stdio.h>
#include <stdlib.h>;
int main(void)
{
int fh,returnValue;
fh = creat("sample.dat", S_IREAD|S_IWRITE);
if (-1 == fh) {
perror("Error creating sample.dat");
return EXIT_FAILURE;
}
if (-1 == (returnValue = __eof(fh))) {
perror("eof function error");
return EXIT_FAILURE;
}
if (1 == returnValue)
printf("File pointer is at end-of-file position.\n");
else
printf("File pointer is not at end-of-file position.\n");
close(fh);
return 0;
/****************************************************************************
The output should be:
File pointer is at end-of-file position.
****************************************************************************/
}
Related Information