C 库函数 - puts()

C 语言教程 · 2019-02-23 22:56:55

描述

C 库函数 int puts(const char *str) 把一个字符串写入到标准输出 stdout,直到空字符,但不包括空字符。换行符会被追加到输出中。

声明

下面是 puts() 函数的声明。

int puts(const char *str)

参数

  • str -- 这是要被写入的 C 字符串。

返回值

如果成功,该函数返回一个非负值,如果发生错误则返回 EOF。

实例

下面的实例演示了 puts() 函数的用法。

#include <stdio.h>
#include <string.h>

int main()
{
   char str1[15];
   char str2[15];

   strcpy(str1, "CODERCTO1");
   strcpy(str2, "CODERCTO2");

   puts(str1);
   puts(str2);
   
   return(0);
}

让我们编译并运行上面的程序,这将产生以下结果:

CODERCTO1
CODERCTO2

点击查看所有 C 语言教程 文章: https://www.codercto.com/courses/l/17.html

查看所有标签

High Performance Python

High Performance Python

Micha Gorelick、Ian Ozsvald / O'Reilly Media / 2014-9-10 / USD 39.99

If you're an experienced Python programmer, High Performance Python will guide you through the various routes of code optimization. You'll learn how to use smarter algorithms and leverage peripheral t......一起来看看 《High Performance Python》 这本书的介绍吧!

URL 编码/解码
URL 编码/解码

URL 编码/解码

html转js在线工具
html转js在线工具

html转js在线工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试