puts ()- 撰寫字串

格式

#include <stdio.h>
int puts(const char *string);

語言層次

ANSI

安全執行緒

說明

puts() 函數會將給定的 字串 寫入標準輸出串流 stdout; 它也會將換行字元附加至輸出。 未寫入結束空值字元。

回覆值

如果發生錯誤, puts() 函數會傳回 EOF 。 非負數回覆值表示未發生任何錯誤。

錯誤碼的值可以設為:
Value
意義
ECONVERT
發生轉換錯誤。
EPUTANDGET
讀取作業之後發生無效的寫入作業。
EIOERROR
發生非可回復I/O錯誤。
EIORECERR
發生可回復I/O錯誤。

範例

此範例會將 Hello World 寫入 stdout
#include <stdio.h>
 
int main(void)
{
  if ( puts("Hello World") == EOF )
    printf( "Error in puts\n" );
}
 
/************************  Expected output:  *********************
 
Hello World
*/

相關資訊