std::putchar
提供: cppreference.com
<tbody>
</tbody>
| ヘッダ <cstdio> で定義
|
||
int putchar( int ch ); |
||
文字 ch を stdout に書き込みます。 内部的に、文字は書き込まれる直前に unsigned char に変換されます。
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 argument
int r = 0x1070;
std::printf("\n0x%x\n", r);
r = std::putchar(r);
std::printf("\n0x%x\n", r);
}
出力:
abcdefghijklmnopqrstuvwxy
0x1070
p
0x70
関連項目
| ファイルストリームに文字を書き込みます (関数) | |
putchar の C言語リファレンス
| |