How it works...
The file whose name is supplied as a command-line argument is opened in read-only mode and is pointed to by the file pointer, fp. This recipe is focused on reading a file and changing its case, so if the file does not exist or does not have read permission, an error will be displayed and the program will terminate.
A while loop will be set to execute until feof (the end of file) is reached. Within the while loop, each line of the file will be read one by one and assigned to the string named buffer. The fgets() function will be used to read one line at a time from the file. A number of characters will be read from the file until the newline character, \n, is reached, to a maximum of 254.
The following steps will be performed ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access