入力から文字単位で読み取り、出力に出力するプログラムを作成しました。これが私のコードです。
#include <stdio.h>
main()
{
int c;
while((c = getchar()) != EOF)
{
printf("%s\n", "log1");
printf("%c\n", c);
printf("%s\n", "log2");
}
}
これが結果です。
a(my input)
log1
a
log2
log1
log2
しかし、次の結果が得られるはずです:
a
log1
a
log2
このプログラムの何が問題になっていますか?