?
? ????? PHP ??? ???? ??? ?? ??
在頭文件<stdio.h>中定義 | ||
---|---|---|
int puts(const char * str); |
將空字符結(jié)尾的字符串str
和一個(gè)附加換行符中的每個(gè)字符寫入'\n'
輸出流stdout
,就像重復(fù)執(zhí)行一樣fputc
。
str
不寫入終止空字符。
str | - | 要寫入的字符串 |
---|
成功時(shí),返回一個(gè)非負(fù)值。
失敗時(shí),返回EOF
并設(shè)置錯(cuò)誤指示器(請(qǐng)參閱參考資料ferror()
)stream
。
該puts
函數(shù)會(huì)將換行符附加到輸出,而fputs
函數(shù)不會(huì)。
不同的實(shí)現(xiàn)返回不同的非負(fù)數(shù):一些返回寫入的最后一個(gè)字符,一些返回寫入的字符數(shù)(或者INT_MAX,如果字符串比這更長(zhǎng)),一些簡(jiǎn)單地返回一個(gè)非負(fù)常數(shù)。
puts
標(biāo)準(zhǔn)輸出重定向到文件時(shí),文件系統(tǒng)空間不足的典型原因是空間不足。
#include <stdio.h> int main(void){ int rc = puts("Hello World"); if (rc == EOF) perror("puts()"); // POSIX requires that errno is set}
輸出:
Hello World
C11標(biāo)準(zhǔn)(ISO / IEC 9899:2011):
7.21.7.9 puts函數(shù)(p:333)
C99標(biāo)準(zhǔn)(ISO / IEC 9899:1999):
7.19.7.10 puts函數(shù)(p:299)
C89 / C90標(biāo)準(zhǔn)(ISO / IEC 9899:1990):
4.9.7.10 puts函數(shù)