Last Update 2012/07/05
標準入力から入力文字を返します。
getc(stdin)と同じものとなります。
getc(stdin)と同じものとなります。
戻り値1 = getchar()
戻り値1 :
int
実行が成功した場合
読み取った文字値
その他の場合
EOF
(例)
#include <stdio.h>
int main()
{
int c;
printf("「EOF」の入力は[control]+D\n");
while ((c = getchar()) != EOF)
{
printf("c = %d\n", c);
}
printf("正常終了 : c = %d\n", c);
return 0;
}
実行結果(「123456[enter]」→「[control]+D」の順で入力)
「EOF」の入力は[control]+D
123456
c = 49
c = 50
c = 51
c = 52
c = 53
c = 54
c = 10
正常終了 : c = -1