Write a C program that loops and asks you every time to enter the name of...

80.2K

Verified Solution

Question

Programming

Write a C program that loops and asks you every time to enterthe name of a text file name, then it will read the file andperform statistics on its contents and display the results to thescreen and to an output file called out.txt. The input files can beany text file.

The program should calculate these integers as it readscharacter by character as we did in the last class example filecopyand make use of the is_functions in ctype.h

int nletters = 0;
int nlower = 0;
int nupper = 0;
int ndigits = 0;
int npuncts = 0;
int nspaces = 0;
int nalnum = 0;//digit or letter
int nlines = 0; //count end of line chars '\n' or EOF

Answer & Explanation Solved by verified expert
4.5 Ratings (766 Votes)
Codeincluding libraries requiredinclude include include int main file pointers FILE fptr1 fptr2 string to store file name and character to read each character from file char filename20 c count to store number of each character int nletters 0 int nlower 0 int nupper 0 int ndigits 0 int npuncts 0 int nspaces 0 int nalnum 0 int nlines 0 taking input from the user name of the file printfEnter the filename to open for readingn scanfs filename opening file fptr1 fopenfilename r if file is empty if fptr1 NULL printfCannot open files n filename exit0 reading each character from file c fgetcfptr1 this loop runs until file reaches theend while c EOF increasing count for everycorresponding character ifisalphac nletters ifisalnumc nalnum    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students