Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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!

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Fundamentals Study Guide

Authors: Dr. Sergio Pisano

1st Edition

B09K1WW84J, 979-8985115307

More Books

Students also viewed these Databases questions