Wednesday, November 27, 2019

C Program for counting number of lines , number of spaces, number of digits in a given file


#include<stdio.h>
#include<ctype.h>
#include<conio.h>
void main(){
FILE *fp = fopen("bb.txt","r");
char c;
int cd=0,cs=0,cl=0;
while((c=getc(fp))!=EOF){

    if(isdigit(c)){
        cd=cd+1;
    }
    else if(isspace(c) && c!='\n'){
        cs=cs+1;
    }
    else if(c=='\n'){
        cl=cl+1;
    }
}
printf("number of digits %d \n",cd);
printf("number of spaces %d \n",cs);
printf("number of lines %d \n",cl);
fclose(fp);
getch();

}




1 comment:

  1. The King Casino - CommunityKhabar
    The King Casino is the only casino near the casino. apr casino All casino games are www.jtmhub.com legal and the game variety communitykhabar is huge! The games are also available at goyangfc any of the

    ReplyDelete