ACP4_6

//BCA Support //www.bcasupport.xyz #include <stdio.h> void main() { FILE *fp; char fname[13],ch; int letter=-1,word=1,line=1; clrscr(); printf("\nEnter file name : "); gets(fname); fp=fopen(fname,"r"); if(fp==NULL) { printf("\nFile not found."); getch(); exit(); } while(!feof(fp)) { ch=fgetc(fp); letter++; if(ch==' '||ch=='\n') word++; if(ch=='\n') { line++; letter--; } } printf("\nCharacters\t: %d",letter); printf("\nWords\t\t: %d",word); printf("\nLines\t\t: %d",line); getch(); }

1 Response

Sir why you declared a= -1 ?

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.