Write a Programm to count words in a given string

*/
/**************************************************************/
/*Programmed by : Vivek Patel**********************************/
/*For Bugs Free feel to contact********************************/
/*Website : www.vivekpatel.cjb.net*****************************/
/*Email : vivek_patel9@rediffmail.com**************************/
/**************************************************************/

#include
#include
void main(){
char s[50],ch;
int i,c=0;
clrscr();
printf("Enter any string : ");
for(i=0;ch!='\n';i++){
ch=getchar();
s[i]=ch;
}
s[i]='\0';

for(i=0;s[i]!='\0';i++){
if(s[i]==' '){
c++;
while(s[i]==' ')
i++;
}
}
printf("\n\nTotal words are %d",c+1);
getch();
}



Powered by Wufoo