首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::putchar

Defined in header <cstdio>

?

?

int putchar( int ch );

?

?

写字符chstdout在内部,字符被转换为unsigned char就在被写出来之前。

相当于putc(ch, stdout)...

参数

ch

-

character to be written

返回值

成功后,返回书写的字符。

失败时,返回EOF并设置误差指标%28见ferror()29%stdout...

二次

代码语言:javascript
复制
#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);
}

二次

产出:

二次

代码语言:javascript
复制
abcdefghijklmnopqrstuvwxy
0x1070
p
0x70

二次

另见

fputcputc

writes a character to a file stream (function)

C.putchar文件

代码语言:txt
复制
 ? cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com