Browse Source

Check if output file actually opened, closes #1

master
Inex Code 3 years ago
parent
commit
5b62521df0
  1. 8
      task1/task1.c

8
task1/task1.c

@ -65,8 +65,12 @@ int main(int argc, char* argv[]) { @@ -65,8 +65,12 @@ int main(int argc, char* argv[]) {
pos = strstr(pos, "777");
}
FILE* output_file = fopen(argv[2], "w");
fwrite(input_file -> contents, sizeof(char), input_file -> size_of_file, output_file);
fclose(output_file);
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;
}

Loading…
Cancel
Save