std::putchar
来自cppreference.com
                    
                                        
                    
                    
                                                            
                    |   定义于头文件  <cstdio>
  | 
||
|   int putchar( int ch );  | 
||
写入字符 ch 到 stdout 。在内部,恰于写入前转换字符为 unsigned char 。
等价于 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 返回值不等于参数 int r = 0x1070; std::printf("\n0x%x\n", r); r = std::putchar(r); std::printf("\n0x%x\n", r); }
输出:
abcdefghijklmnopqrstuvwxy 0x1070 p 0x70
参阅
|   写字符到文件流  (函数)  |