cin默认会略过空格的,可以用getline() #include #include using namespace std ;int main(){ string s1; cout << "Enter a sentence (use <换行符> as the delimiter): "; getline(cin,s1, '\n'); cout << "You entered: " << s1 << endl;;}