Created
June 8, 2015 19:24
-
-
Save mikezackles/5fae14f3a0bed5fb13ac to your computer and use it in GitHub Desktop.
goto error_handling;
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int read_file_normal(const char* filename) | |
{ | |
FILE* f = fopen(filename, "rt"); | |
char buf[100]; | |
if (f == NULL) { | |
fprintf(stderr, "Failed to open %s", filename); | |
goto error_open; | |
} | |
if (fread(buf, sizeof(buf), 1, f) == 0) { | |
fprintf(stderr, "Failed to read data from %s\n", filename); | |
goto error_read; | |
} | |
if (fclose(f) == EOF) { | |
fprintf(stderr, "Failed to close %s\n", filename); | |
} | |
return 0; | |
error_read: | |
fclose(f); | |
error_open: | |
return -1; | |
} |
LBiv
commented
Jun 8, 2015
<interrupted else-if chain>
if(error) {
}
else if(exp) {
...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment