C 语言的字符串函数 puts()
属于标准库 <stdio.h>
函数原型:
int puts(const char *str)
str – 这是要被写入的 C 字符串.
如果成功, 该函数返回一个非负值为字符串长度 (包括末尾的 \0), 如果发生错误则返回 EOF.
作用: puts() 函数只显示字符串, 把一个字符串写入到标准输出 stdout, 直到空字符, 但不包括空字符. 行末自动添加换行符.
程序示例:
#include<stdio.h>int main(void)
{char str1[] = "hello";puts(str1);puts(str1);return 0;
}
结果:
hello
hello
可以看出自动换行了.