私は、ユーザーに文字のストリームを入力して、大文字と小文字の数を出力するように求めるプログラムを実行しています。私は関数でそれをやろうとしていますが、それを印刷するのに問題があります..すべての文字入力に対してim入力im取得im取得0, 0
私が間違っていることを理解するためにあなたの助けをいただければ幸いです:
#include <stdio.h>
#include <ctype.h>
int case_letters(int ch);
int main(void)
{
int x;
printf("please enter a some characters, and ctrl + d to see result\n");
case_letters(x);
return 0;
}
int case_letters(int ch)
{
int numOfUpper = 0;
int numOfLower = 0;
while ((ch = getchar()) != EOF)
{
if ((ch = isdigit(ch)) || ch == '\n')
{
printf("please enter a valid character\n");
continue;
}
else if ((ch = isupper(ch)))
{
numOfUpper++;
}
else if ((ch = islower(ch)))
{
numOfLower++;
}
}
return printf("%d, %d", numOfUpper, numOfLower);
}