Check the end-of-file status of a stream.
Compatibility:This function is compatible with the following targets:
|
|
#include <stdio.h>
int feof(FILE *stream);Parameters:
Parameters for this facility are:
NOTE
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
FILE *f;
static char filename[80], buf[80] = "";
// get a filename from the user
printf("Enter a filename to read.\n");
gets(filename);
// open the file for input
if (( f = fopen(filename, "r")) == NULL) {
printf("Can't open %s.\n", filename);
exit(1);
}
// read text lines from the file until
// feof() indicates the end-of-file
for (; feof(f) == 0 ; fgets(buf, 80, f) )
printf(buf);
// close the file
fclose(f);
return 0;
}
Output:
Enter a filename to read.
itwerks
The quick brown fox
jumped over the moon.
[ First ] [ Previous ] [ Next ] [ Last ] [ Manuals ]
Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.
Last updated: August 16, 2000