#include<stdio.h>
#include<conio.h>
void main()
{
FILE *fp;
int noc=0,now=0,nol=0,not=0;
char ch;
clrscr();
fp=fopen("a.txt","r");
if (fp==NULL)
{
printf("\n unable to open file");
}
while ((ch=fgetc(fp))!=EOF)
{
if(ch==EOF)
break;
noc++;
if(ch==' ')
now++;
if(ch=='\n')
nol++;
if(ch=='\t')
not++;
}
fclose(fp);
printf("\n The number of chracter are%d",noc);
printf("\n The number of word are %d",now);
printf("\n The number of lines are %d",nol);
printf("\n The number of tabs are %d",not);
getch();
}
#include<conio.h>
void main()
{
FILE *fp;
int noc=0,now=0,nol=0,not=0;
char ch;
clrscr();
fp=fopen("a.txt","r");
if (fp==NULL)
{
printf("\n unable to open file");
}
while ((ch=fgetc(fp))!=EOF)
{
if(ch==EOF)
break;
noc++;
if(ch==' ')
now++;
if(ch=='\n')
nol++;
if(ch=='\t')
not++;
}
fclose(fp);
printf("\n The number of chracter are%d",noc);
printf("\n The number of word are %d",now);
printf("\n The number of lines are %d",nol);
printf("\n The number of tabs are %d",not);
getch();
}