Title description
The Description
Enter a string, count the number of letters.
The input description
Input
A string that contains no Spaces (length is less than 100)
Output description
The Output
The number of letters in string
Sample input
Input example
124 lfdk54aiej92854 & amp; % $GJ
Sample output
The Output example
10
Here is my code
I don't know where is wrong
#include
Int main ()
{
char ch;
int count=0;
int i;
While (getchar ()!=(EOF)
{
If (getchar () & gt;='A' & amp; & Getchar () & lt;='Z')
{
count++;
}
If (getchar () & gt;='a' & amp; & Getchar () & lt;='z')
{
count++;
}
I=count;
}
Printf (" % d ", I);
return 0;
}
CodePudding user response:
# include
#include
Int main ()
{
//char ch;
Int ch;
int count=0;
int i;
While ((ch=getchar ())!=(EOF)
{
If (ch=='\ n')
break;
If # 1
If (ch & gt;='A' & amp; & Ch<='Z')
{
count++;
}
Else if (ch>='a' & amp; & Ch<='z')
{
count++;
}
# the else
If (isalpha (ch))
count++;
# endif
//I=count;
}
//printf (" % d ", I);
Printf (" % d \ n ", count);
return 0;
}
For your reference ~
CodePudding user response:
In brief, each getchar (), will read one character at a time, and on the comparison, do not save,This kind of behavior in the northeast words called bear blind split (3) and corn, splitting a throw a root,