Loose-Info.com
Last Update 2012/07/05
TOP - C言語 - stdio.h - fputc()

ファイル・ポインタで参照されるストリームに、指定された文字を出力します。
putc()と基本的に同じ動作ですが、関数として定義されています。

 戻り値1  = putc(  引数1  ,  引数2  )

戻り値1 :
int
実行が成功した場合
出力された文字値
エラーが発生した場合
EOF
引数1 :
int
出力する文字値
引数2 :
FILE *
ファイル・ポインタ

(例)
#include <stdio.h> int main() { int c1; int c2; printf("「EOF」の入力は[control]+D\n"); while ((c1 = getchar()) != EOF) { c2 = fputc(c1, stdout); printf(" : c2 = %d\n", c2); } printf("正常終了 : c1 = %d\n", c1); return 0; }

実行結果(「123456[enter]」→「[control]+D」の順で入力)
「EOF」の入力は[control]+D 実行中... 123456 1 : c2 = 49 2 : c2 = 50 3 : c2 = 51 4 : c2 = 52 5 : c2 = 53 6 : c2 = 54 : c2 = 10 正常終了 : c1 = -1