I'm attempting to exit a while loop, based on file contents. File exists and is empty, or garbage filled at initialization of the program. I externally modify the file, and would like the loop to exit upon this happening based on how the file was modified.
Currently, I start a few threads, open the file that I'm reading from. Check the first byte. If it is a one, I exit, else start the loop.
When I'd like to exit. I put a one in the first byte, but it appears my file is never read again.
While loop statement and variable definition each loop looks like:
while(strcmp(fileContents, "1\n") != 0){
lengthRead = fread(fileContents, 1, size, isRecording);
fseek(isRecording, 0, SEEK_SET);
I know there are probably simpler ways to exit a while loop externally, but based on the architecture of my project, the only way I can see how to control this is to exit based on file contents.