This is part of my homework using structs in C and I can\'t figure it out. Pleas
ID: 3762723 • Letter: T
Question
This is part of my homework using structs in C and I can't figure it out. Please answer using C not C++ or Java, thanks. I will rate and award points to all usefull answers. Thanks!
We will analyze text using the following methods given input file. You will ask user to give you file name and then perform each of the following analysis. Each analysis method will print a table of results:
Number of occurrences in file of each letter
Number of words in file with...
one-letter word
two-letter word
n-letter word
Number of times word used in file
Explanation / Answer
#include #include void main() { FILE *p,*q; char file1[20],file2[20]; char ch; int c=0,w=0,l=1; clrscr(); printf(" enter the source file name be copied:"); gets(file1); p=fopen("file1.txt","r"); if(p==NULL) { printf("cannot open %s",file1); exit (0); } printf(" enter the destination file name:"); gets(file2); q=fopen("file2.txt","w"); if(q==NULL) { printf("cannot open %s",file2); exit (0); } while((ch=getc(p))!=EOF) { if(ch==' ') w++;
if(ch==' ') l++; c=ftell(p); putc(ch,q); } printf(" numner of characters %d",c); printf(" numner of words %d",w+l); printf(" numner of lines %d",l); fclose(p); fclose(q); getch(); }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.