?
Dokumen ini menggunakan Manual laman web PHP Cina Lepaskan
在頭文件<stdio.h>中定義 | ||
---|---|---|
int puts(const char * str); |
將空字符結(jié)尾的字符串str
和一個附加換行符中的每個字符寫入'\n'
輸出流stdout
,就像重復(fù)執(zhí)行一樣fputc
。
str
不寫入終止空字符。
str | - | 要寫入的字符串 |
---|
成功時,返回一個非負(fù)值。
失敗時,返回EOF
并設(shè)置錯誤指示器(請參閱參考資料ferror()
)stream
。
該puts
函數(shù)會將換行符附加到輸出,而fputs
函數(shù)不會。
不同的實現(xiàn)返回不同的非負(fù)數(shù):一些返回寫入的最后一個字符,一些返回寫入的字符數(shù)(或者INT_MAX,如果字符串比這更長),一些簡單地返回一個非負(fù)常數(shù)。
puts
標(biāo)準(zhǔn)輸出重定向到文件時,文件系統(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ù)