#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
main()
{
int l=0,c=0,t=0,s=0;
char ch;
FILE *fp;
clrscr();
fp=fopen("p-swap.cpp","r");
if(fp==NULL)
{
printf("Cannot open the file");
getch();
exit(0);
}
while(1)
{
ch=fgetc(fp);
c++;
if(ch==EOF)
break;
if(ch=='\n')
l++;
if(ch=='\t')
t++;
if(ch==' ')
s++;
printf("%c",ch);
}
fclose(fp);
printf("\nNumber of Characters|| %d",c);
printf("\nNumber of Lines || %d",l);
printf("\nNumber of Tabs || %d",t);
printf("\nNumber of Spaces || %d",s);
getch();
}
0 comments:
Post a Comment