©
이 문서에서는PHP 중국어 웹사이트 매뉴얼풀어 주다
在头文件 |
|
|
---|---|---|
int putchar(int ch); |
|
|
将一个字符写入ch
到stdout
。在内部,字符unsigned char
在被写入之前被转换。
Equivalent toputc(ch,
stdout)
.
ch |
- |
character to be written |
---|
成功时,返回书面字符。
失败时,返回EOF
并设置错误指示器(请参阅参考资料ferror()
)stdout
。
带错误检查的putchar。
#include#include int main(void){ int ret_code = 0; for (char c = 'a'; (ret_code != EOF) && (c != 'z'); c++) ret_code = putchar(c); /* Test whether EOF was reached. */ if (ret_code == EOF) if (ferror(stdout)) { fprintf(stderr,"putchar() failed in file %s at line # %d\n", __FILE__,__LINE__-6); perror("putchar()"); exit(EXIT_FAILURE); } putchar('\n'); // putchar return value is not equal to the argument int r = 0x1070; printf("\n0x%x\n", r); r = putchar(r); printf("\n0x%x\n", r);}
输出:
abcdefghijklmnopqrstuvwxy 0x1070p0x70
C11标准(ISO / IEC 9899:2011):
7.21.7.8 putchar函数(p:333)
C99标准(ISO / IEC 9899:1999):
7.19.7.9 putchar函数(p:299)
C89 / C90标准(ISO / IEC 9899:1990):
4.9.7.9 putchar函数