put ()- 编写字符串

格式

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

语言级别

ANSI

线程安全

描述

puts() 函数将给定的 string 写入标准输出流 stdout; 它还会将换行符附加到输出。 未写入结束空字符。

返回值

如果发生错误, puts() 函数将返回 EOF 。 非负返回值指示未发生任何错误。

errno 的值可以设置为:
含义
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
*/

相关信息