?
Ce document utilise Manuel du site Web PHP chinois Libérer
在頭文件<stdio.h>中定義 | ||
---|---|---|
int fputs(const char * str,F(xiàn)ILE * stream); | (直到C99) | |
int fputs(const char * restrict str,F(xiàn)ILE * restrict stream); | (自C99以來) |
將空字符串str
中的每個字符寫入輸出流stream
,就像重復(fù)執(zhí)行一樣fputc
。
str
不寫入終止空字符。
str | - | 以空字符結(jié)尾的字符串進(jìn)行寫入 |
---|---|---|
流 | - | 輸出流 |
成功時,返回一個非負(fù)值。
失敗時,返回EOF
并設(shè)置錯誤指示器(請參閱參考資料ferror()
)stream
。
相關(guān)函數(shù)puts
將追加一個換行符作為輸出,同時fputs
寫入未修改的字符串。
不同的實(shí)現(xiàn)返回不同的非負(fù)數(shù):一些返回寫入的最后一個字符,一些返回寫入的字符數(shù)(或者INT_MAX,如果字符串比這更長),一些簡單地返回一個非負(fù)常數(shù),例如零。
#include <stdio.h> int main(void){ int rc = fputs("Hello World", stdout); if (rc == EOF) perror("fputs()"); // POSIX requires that errno is set}
輸出:
Hello World
C11標(biāo)準(zhǔn)(ISO / IEC 9899:2011):
7.21.7.4 fputs函數(shù)(p:331-332)
C99標(biāo)準(zhǔn)(ISO / IEC 9899:1999):
7.19.7.4 fputs函數(shù)(p:297)
C89 / C90標(biāo)準(zhǔn)(ISO / IEC 9899:1990):
4.9.7.4 fputs函數(shù)