Answers for "get vector input from string in c++"

C++
0

get vector input from string in c++

vector<int> getVectorInput(string s){
    string res="";
    vector<int> arr;
    for(auto e : s){
        if(e==' '){
            if(res.size()!=0)
            arr.push_back(stoi(res));
            res="";
            continue;
        }
        res+=e;
    }
    if(res.size()!=0)
        arr.push_back(stoi(res));
    return arr;
}
Posted by: Guest on September-23-2021

Code answers related to "get vector input from string in c++"

Browse Popular Code Answers by Language