我使用scanf()将输入作为字符串,但是使用cout输出。为什么我的程序终止?

问题描述 投票:-1回答:1

我使用scanf()将输入作为字符串,但是使用cout输出。为什么我的程序在不显示输出的情况下终止?

string s;
scanf("%s",&s);
cout <<s<<endl;
string scanf
1个回答
0
投票
scanf使用c字符串(字符数组)。请改用getline
© www.soinside.com 2019 - 2024. All rights reserved.