Home > Back-end >  Something wrong with the word count is not running?
Something wrong with the word count is not running?

Time:10-04

#include
# define N 100
Int main ()
{
Char * a, [N].
Int j=0, I=0;
Printf (" both Please input some words: \ n ");
Gets (* a);
While (* a [I]!='\ 0')
If (* a [I]==' ')
J++ i++;
Printf (" Words' number is % d ", j);
return 0;
}

CodePudding user response:

Char * a, [N]. - & gt; Char a, [N].
Gets (* a); - & gt; Gets (a);

CodePudding user response:

 # include 
# define N 100
Int main ()
{
Char a, [N].
Int j=0, I=0;
Printf (" both Please input some words: \ n ");
The fgets (a, N, stdin);
While (a [I]!='\ 0') {
If (a [I]==' ')
J++ i++;
The else
i++;
}
j++;
Printf (" Words' number is % d ", j);
return 0;
}

For your reference ~

If little else i++, while loop may be infinite loop ~
  • Related