hey.
Code:
#include <stdio.h>
FILE *fp;
int main (void)
{
int x;
char filename[80], buf[200];
puts("Enter file to review");
scanf("%s", filename);
if ((fp = fopen(filename, "r")) == NULL)
{
puts("Error1");
return(-1);
}
while(1)
{
if (fgets(buf, 200, fp) == NULL)
{
puts("Error2 or EOF");
return(-1);
}
printf("%s", buf);
}
return 0;
}
anyone who can tell me about a way of checking for EOF within this while loop. I can't think of a good sollution. I would like to print an error if something else than EOF is found by fgets.
dagH