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

std::fputc

Defined in header <cstdio>

?

?

int fputc( int ch, std::FILE* stream ); int putc( int ch, std::FILE* stream );

?

?

写字符ch到给定的输出流。stream...

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

在C中,putc()可以作为宏实现,在C++中是不允许的。因此调用std::fputc()std::putc()总是有同样的效果。

参数

ch

-

character to be written

stream

-

output stream

返回值

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

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

二次

代码语言:javascript
复制
#include <cstdio>
 
int main()
{
    for (char c = 'a'; c != 'z'; c++)
        std::putc(c, stdout);
    std::putc('\n', stdout);
 
    // 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

二次

另见

putchar

writes a character to stdout (function)

c fputc,putc的文档

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

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

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com