Question: Write the following function: int count_characters (const char filename) The function should open, read, and close the file, and return the number of characters in

Write the following function: int count_characters (const char filename) The function should open, read, and close the file, and return the number of characters in the text file whose name is filename. If there is no character in the file or the file does not exit, the function should return 0. Assume the maximum number of characters in each line is 1000. You might need the file reading function fgets. The function prototype of fgets is: char* fgets (char* buffer, int max, FILE* pFile) int count_characters (char *filename) char str [1001]: FILE* pFile; int count 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
