How to use EOF to run through a text file in C? - Stack Overflow

PHOTO EMBED

Sun Mar 27 2022 23:48:02 GMT+0000 (Coordinated Universal Time)

Saved by @danihf23 #c

char buffer[BUFFER_SIZE];
while (fscanf(stream, "%s", buffer) == 1) // expect 1 successful conversion
{
  // process buffer
}
if (feof(stream)) 
{
  // hit end of file
}
else
{
  // some other error interrupted the read
}
content_copyCOPY

https://stackoverflow.com/questions/1835986/how-to-use-eof-to-run-through-a-text-file-in-c