字符串分隔

#include <sstream>
int main(){
    vector<string> arr;
    string s;
    getline(cin, s);
    stringstream ss(s);
    while(getline(ss, s, ' ')){
        arr.push_back(s);
    }
    for(auto &it:arr){
        cout<<it<<" ";
    }

    return 0;
}
posted @ 2021-08-29 11:02  蘑菇王国大聪明  阅读(29)  评论(0)    收藏  举报