HP C/iX Library Reference Manual (30026-90004)

146 Chapter5
HP C/iX Library Function Descriptions
feof
fprintf("Can't open %s.\n", argv[1]);
exit(1);
}
datale = fopen("dfle", "w");
if(datale == NULL) {
fprintf("Can't create dfle file.\n");
exit(1);
}
datagt = fopen("dfgt", "w");
if(datagt == NULL) {
fprintf("Can't create dfgt file.\n");
exit(1);
}
for(;;) {
if((c = fgetc(dfile)) != EOF) {
if(c <= 'Z' c >= 'A')
fputc(c, datale);
else
fputc(c, datagt);
} else {
if(feof(dfile))
break;
else
fprintf(stderr, "error in reading file \n");
exit(1);
}
}
exit(0);
}
Whenever fgetc() returns an integer equal to EOF, the feof() function checks whether
the end-of-file has been reached. If the end-of-file has been reached, the loop and the
program terminate; if not, an error message is displayed and the program terminates.
See Also
fopen(), ferror(), ANSI C 4.9.10.2, POSIX.1 8.1