在C语言中,可以使用scanf函数或gets函数来输入字符串。
使用scanf函数:
#include <stdio.h>int main() { char str[100]; printf("请输入字符串:"); scanf("%s", str); printf("您输入的字符串是:%s\n", str); return 0;}使用gets函数:
#include <stdio.h>int main() { char str[100]; printf("请输入字符串:"); gets(str); printf("您输入的字符串是:%s\n", str); return 0;}注意:使用gets函数时要注意字符串的长度,避免溢出。推荐使用fgets函数来输入字符串,可以指定字符串的最大长度,避免溢出问题。

