Check if output file actually opened, closes #1

This commit is contained in:
Inex Code 2020-03-05 17:14:12 +03:00
parent b5904455de
commit 5b62521df0

View file

@ -65,8 +65,12 @@ int main(int argc, char* argv[]) {
pos = strstr(pos, "777");
}
FILE* output_file = fopen(argv[2], "w");
if (output_file == NULL) {
fprintf(stderr, "Error opening output file");
} else {
fwrite(input_file -> contents, sizeof(char), input_file -> size_of_file, output_file);
fclose(output_file);
}
close_file(input_file);
return 0;
}