Exiting out of file with feof function
问题 I am trying to make a photo extraction program stop when it detects it is at the end of the file to be extracted. I did this by placing an if condition: if (feof(file)) { return 2; } After a fread function: fread(array, 1, 512, file); So that if fread reads to the end of the file, then feof will trigger and thereby end the program. This is my code: #include <stdio.h> #include <stdlib.h> #include <stdbool.h> int main(int argc, char *argv[]) { if (argc != 2) { printf("Invalid entry.\n"); return