Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Meet and Greet (http://www.go4expert.com/community/meet-and-greet/)
-   -   Filing Help In C Language (http://www.go4expert.com/community/filing-help-c-language-t24014/)

global956 27Nov2010 18:50

Filing Help In C Language
 
// A program to read a file and check how many vowels, spaces and consonents are there in a file
My Questions:

// A program to read a file and check how many words are there in a file


// A program to read a file and check how many characters are there in a file

can anyone solve these questions using below program.Please help me i am new in this form.
Code:

# include <stdio.h>
# include <conio.h>
# include <stdlib.h>

void main ()

{ clrscr();
char ch;
FILE *fptr;
int a = 0,e = 0,i = 0,o = 0,u = 0,c = 0,s=0,sum ;
if ((fptr = fopen("jawwad.txt","r"))== NULL)
{
printf("Can't open the file");
getch();
exit(1);}

while ((ch =getc(fptr))!= EOF){
printf("%c",ch);
switch(ch)
{
case 'a':
a++; break;

case 'e':
e++; break;
case 'i':
i++; break;
case 'o':
o++; break;
case 'u':
u++; break;
case '':
s++;break;
default:
c++;

}
}
printf(" \na=%d, \ne=%d, \ni=%d, \no=%d, \nu=%d, \ns=%d, \nc=%d",a,e,i,o,u,s,c);
{
sum=a+e+i+o+u+s+c;
printf("\nThe sum is %d",sum);
}
fclose(fptr);
getch();
}

My Questions:

// A program to read a file and check how many words are there in a file


// A program to read a file and check how many characters are there in a file

can anyone solve these questions using above program


All times are GMT +5.5. The time now is 21:55.