std::putchar
提供: cppreference.com
ヘッダ <cstdio> で定義 | ||
int putchar(int ch ); | ||
文字 ch
を stdout
に書き込みます。 内部的に、文字は書き込まれる直前に unsignedchar に変換されます。
putc(ch, stdout) と同等です。
目次 |
[編集]引数
ch | - | 書き込まれる文字 |
[編集]戻り値
成功した場合は、書き込まれた文字を返します。
失敗した場合は、 EOF を返し、 stdout のエラー指示子 (ferror() を参照) をセットします。
[編集]例
Run this code
#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
[編集]関連項目
ファイルストリームに文字を書き込みます (関数) | |
putchar の C言語リファレンス |