C language beginner, why can't I write output?
CodePudding user response:
To this:
while ((ch=getchar ())!='\ n')
If you use the
while (ch=getchar ()!='\ n')
This ch is true or false
CodePudding user response:
Input is a string, not a single character, modified as follows, for reference:
# include & lt; stdio.h>
Int main (int arg c, char * argv [])
{
Int vowel (char ch);
Int x, sum=0, I=0;
Char ch [80].
Gets (ch);
While (ch [I]!='\ 0') {
If (vowel (ch) [I])
The sum +=1;
i++;
}
Printf (" % d ", sum);
system("pause");
return 0;
}
Int vowel (char ch)
{
If (ch=='A' | | ch=='A' | | ch=='E' | | ch=='E' | | ch=='I' | | ch=='I' | | ch=='o' | | ch=='o')
return 1;
return 0;
}
CodePudding user response:
While (ch=getchar ()! )
='\ n'
The following instead, give it a try: