我有一个我想在我的应用程序上实现的步骤的示例程序。我想将字符串上的 int 元素分别 push_back 到一个向量中。我怎样才能?
#include <iostream>
#include <sstream>
#include <vector>
using namespace std;
int main(){
string line = "1 2 3 4 5"; //includes spaces
stringstream lineStream(line);
vector<int> numbers; // how do I push_back the numbers (separately) here?
// in this example I know the size of my string but in my application I won't
}