C++。向string类型变量输入一行字符串。空格也要进去

向string类型变量输入一行字符串。空格也要进去。怎么写代码
2025-03-23 01:48:11
推荐回答(1个)
回答(1):

#include #include using namespace std ; int main() { string s1; cout << "Enter a sentence: "; getline(cin,s1); cout << "You entered: " << s1 << endl;; }