How it works...
We will open the chosen sequential file in read-only mode. If the file opens successfully, it will be pointed at by the file pointer, fp. To count the number of vowels in the file, we will initialize a counter from 0.
We will set a while loop to execute until the file pointer, fp, reaches the end of the file. Within the while loop, each line in the file will be read using the fgets function. The fgets function will read the BUFFSIZE number of characters from the file. The value of the BUFFSIZE variable is 255, so fgets will read either 254 characters from the file or will read characters until the newline character, \n, is reached, whichever comes first.
The line read from the file is assigned to the buffer string. To display ...
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