#include<stdio.h>
main()
{
FILE *fp;
char c;
int i,s=0,l=0,sp=0,ch=0,d=0;
clrscr();
fp=fopen("file1","w");
while((c=getchar())!=EOF)
putc(c,fp);
fclose(fp);
fp=fopen("file1","r");
while((c=getc(fp))!=EOF)
{
i=c;
if(c>='0'&&c<='9') d++;
else if(i>=65&&i<=90)ch++;
else if(i>=97&&i<=122)ch++;
else if(c=='\n')l++;
else if(c==' ')s++;
else sp++;
}
fclose(fp);
printf("\nDIGITS:%d",d);
printf("\nCHARACTERS:%d",ch);
printf("\nSPACES:%d",s);
printf("\nWORDS:%d",++s);
printf("\nLINES:%d",++l);
printf("\nSPECIAL CHARACTERS:%d",sp);
getch();
}
Hai welcome to file.
^Z
DIGITS:0
CHARACTERS:16
SPACES:3
WORDS:4
LINES:2
SPECIAL CHARACTERS:1
Contact:
Mr. Roshan P. Helonde
Mobile: +91-7276355704
WhatsApp: +91-7276355704
Email: roshanphelonde@rediffmail.com