入力された文字列の最初の非空白文字を返す関数を作成するように依頼されました。
「こんにちは」など、空白で始まらないものを入力すると機能します。しかし、「こんにちは」のようなものを入力すると、空白が返されます。
これが私のコードです:
int question6()
{
printf("Start typing stuff in \n");
char myChar = returnFirstNonWhite();
printf("First non-white space character is: %c",myChar);
}
int returnFirstNonWhite()
{
int ch,temp;
ch = getchar();
while (ch != 32)
{
temp = ch;
printf("Found first success %c\n", ch);
}
return temp;
}