Question: Reads a character string and counts the existing words */ #include void main() { char line[81], *pline ; int cword =0; printf( Enter a string
Reads a character string and counts the existing words */
#include
void main()
{ char line[81], *pline ;
int cword =0;
printf( Enter a string of characters :);
gets(line);
for (pline=line; *pline == , pline++); // Skips blanks.
while (pline !=\0)
{ cword ++;
for ( ; ((pline !=\0) and ( *pline!= ); pline++) ; // skips letters
for ( ; ((pline !=\0) and ( *pline== ); pline++) ; // skips blanks
}
printf(There are %d words in the string.,cword);
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
