c++中对于字符串的输入输出一般用cin,cout,但是对于大量的输入和输出,cin和cout会消耗大量的时间,可以用以下操作实现scanf和printf的输入输出。
#include<cstdio>
#include<string>
using namespace std;
int main()
{
char p[30];
scanf_s("%s", p, 30); // 也可写成&p
printf("%s\n", p);
return 0;
}
c++中对于字符串的输入输出一般用cin,cout,但是对于大量的输入和输出,cin和cout会消耗大量的时间,可以用以下操作实现scanf和printf的输入输出。
#include<cstdio>
#include<string>
using namespace std;
int main()
{
char p[30];
scanf_s("%s", p, 30); // 也可写成&p
printf("%s\n", p);
return 0;
}