文章目录
目录
一、使用scanf
二、使用getchar
三、使用gets函数
一、使用scanf
示例:
使用scanf可以输入字符串,但只能输入中间没有空格的字符串,输入有空格的字符串他会把空格当作结束标志。

二、使用getchar

getchar是从控制台获取一个字符,赋予给一个char类型变量,再把字符存放到数组中,需要另外创建一个char类型和int类型变量,且通过while循环来实现,可以输入带空格字符串。
三、使用gets函数

函数介绍


在完成复制后会返回str的首地址。
使用gets函数也可以输入有空格的字符串。