Monday, October 31, 2022

[FIXED] How to determine, inside of "while(fscanf != EOF){blah}", if the next fscanf is going to return EOF?

Issue

I've got some code executing in a while(fscanf != EOF) loop. However, even when fscanf has finished executing, I need to keep running that code until some conditions are met. I mean I guess I could copy/paste the code to outside the while(fscanf) loop, and only use global variables, but that seems messy. Surely someone has encountered something like this before and has a cleaner solution.


Solution

Couldn't you just modify the while condition to account for these additional conditions?

while(fscanf(...) != EOF || !(some_other_conditions_met)) 


Answered By - Andreas Brinck
Answer Checked By - Gilberto Lyons (PHPFixing Admin)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.