I'm learning about code used to open files.
I got the following code from "Sam's Teach Yourself C for Linux Programming"
I don't understand why he set filename[ ] and mode [ ] to 0.
/*demonstrating the fopen( )*/
char ch, filename, mode;
printf("\nEnter a filename: ");
fgets(filename, 40, stdin);
filename[ strlen(filename) - 1] = 0; /*sets filename[ ] to 0 ????*/
printf("\nEnter a mode (max 3 characters): ");
fgets(mode, 5, stdin);
mode [ strlen(mode) - 1] = 0; /*sets mode[ ] to 0 ????*/
/*then opens file with--- */
if ( ( fp = fopen( filename, mode ) ) != NULL )
/* etc. .....*/