N
No Such Luck
Hi All:
I have a loop in which I scan an entire file for a particular string
("Error:"). However, I don't know the specifics of testing for the EOF.
while (1) /* This should be while (!EOF) or something */
{
fscanf (file, "%s", string);
if (!strcmp (string, "Error:"));
{
error = 1;
break;
}
}
Of course, if the string "Error:" is not present in the file, this
becomes an infinite loop. What test must be done, and where, to break
out of the loop when the EOF is encountered?
Thanks...
P.S. I checked the FAQ, and only 2 questions/answers were related to
EOFs. Neither seems appropriate for this question.
I have a loop in which I scan an entire file for a particular string
("Error:"). However, I don't know the specifics of testing for the EOF.
while (1) /* This should be while (!EOF) or something */
{
fscanf (file, "%s", string);
if (!strcmp (string, "Error:"));
{
error = 1;
break;
}
}
Of course, if the string "Error:" is not present in the file, this
becomes an infinite loop. What test must be done, and where, to break
out of the loop when the EOF is encountered?
Thanks...
P.S. I checked the FAQ, and only 2 questions/answers were related to
EOFs. Neither seems appropriate for this question.