My program fails to recover the last JPEG. I see all the JPEGs but CS50 Check doesn't see the last file. I checked it with Valgrind and had no memory leaks. I suspect it has something to do with EOF but I'm not sure... The code is: (removed due to academic honesty) Any suggestions?
Maybe check50 does see the last image, but it is not correct! It likely has some "junk" at the end because of this
while (!feof(inptr));. Your eyes cannot detect it, but check50 sure can. This short from last year's courseware describes the problem with this usage very well, starting around 7:30. As Jason explains:
....the purpose of feof is not to check if the next call to a read function will hit the end of the file, but rather to check whether or not the end of the file has already been reached. In the case of this example, reading the last line of our file goes perfectly smoothly, but the program doesn't yet know that we've hit the end of our file. It's not until it does one additional read that it counters the end of the file.