名前空間
変種
操作

std::putchar

提供: cppreference.com
< cpp‎ | io‎ | c
 
 
 
 
ヘッダ <cstdio> で定義
int putchar(int ch );

文字 chstdout に書き込みます。 内部的に、文字は書き込まれる直前に unsignedchar に変換されます。

putc(ch, stdout) と同等です。

目次

[編集]引数

ch - 書き込まれる文字

[編集]戻り値

成功した場合は、書き込まれた文字を返します。

失敗した場合は、 EOF を返し、 stdoutエラー指示子 (ferror() を参照) をセットします。

[編集]

#include <cstdio>   int main(){for(char c ='a'; c !='z'; c++) std::putchar(c); std::putchar('\n');   // putchar return value is not equal to the argumentint r =0x1070;std::printf("\n0x%x\n", r); r = std::putchar(r);std::printf("\n0x%x\n", r);}

出力:

abcdefghijklmnopqrstuvwxy 0x1070 p 0x70

[編集]関連項目

ファイルストリームに文字を書き込みます
(関数)[edit]
close