请问这个用c++怎么写
# include <stdio.h>
int main(void)
{
char str[10]; //str是string的缩写, 即字符串
printf("请输入字符串:");
scanf("%s", str); /*输入参数是已经定义好的“字符数组名”, 不用加&, 因为在C语言中数组名就代表该数组的起始地址*/
printf("输出结果:%s\n", str);
return 0;
}
你的函数可以直接用gets(m)函数,gets(m)函数的目的就是获取输入的数据。m应该为char型数组
或者可以用scanf("%s",a),这里的a是一个char型的数组
#include <iostream>
#include <string>
using namespace std;
int main()
{
string strValue;
cin >> strValue;
cout << strValue;
return 0;
}