Question: Please explain why the answer is what is is thoroughly. I am trying to study for my test. I will make sure to thumbs up!

 Please explain why the answer is what is is thoroughly. I

Please explain why the answer is what is is thoroughly. I am trying to study for my test. I will make sure to thumbs up! thank you very much for your time

int count_characters(char *filename) {

char str[1001]; FILE* pFile; int count = 0;

pFile = fopen(filename, "r");

if (pFile == NULL) {

printf ("Error opening file ");

return 0; }

while ( fgets (str, MAX_LEN, pFile ) != NULL ) {

count += strlen(str); }

fclose(pFile); return count;

}

16. Write the following function: int count characters (const char filename int n) The function should 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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!