Skip to content

Commit

Permalink
now checks for empty file name
Browse files Browse the repository at this point in the history
  • Loading branch information
Gavinok committed Oct 15, 2019
1 parent e4709b4 commit fc4804a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion RLE.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@ int main(int argc, char *argv[])

/* OPEN FILE */
const char *filename = argv[1];
/* check if the filename is completely empty*/
if ( !strcmp(filename, "") ) {
printf("Error: No input file specified!\n");
exit(1);
}
FILE *file_pointer = fopen(filename, "r");
if (file_pointer == NULL) {
fprintf(stderr, "Read error: file not found or cannot be read\n");
printf("Read error: file not found or cannot be read\n");
exit(2);
}
/* FILE IS NOW OPEN */
Expand Down

0 comments on commit fc4804a

Please sign in to comment.