Im a beginner in C,Can anyone help me? :?:
I have problems when I encounter double or multiple spaces between words.
#include <stdio.h>
FILE *fpr;
int main(int argc,char *argv[])
{
if ((fpr = fopen(argv[1],"r")) == 0)
{
printf ("\nFile %s Don't Exist!\n", argv[1]);
}
fprintf (fpr,"%d",count());
return(0);
}
count()
{
char ch;
int word=0;
while(feof(fpr) == 0)
{
ch= getc(fpr);
if(ch == ' ')
{
word++;
}
else if(ch == '\n')
{
word++;
}
}
printf("Number of Words : %d\n",word);
}
Thank You :)