我知道有字符串标记符,但是有"int tokenizer"吗?
例如,我想拆分字符串"12 34 46"并具有:
列表[0] = 12
列表[1] = 34
列表[2] = 46
特别是,我想知道Boost :: Tokenizer是否这样做.虽然我找不到任何不使用字符串的示例.
我有一个步骤的示例程序,我想在我的应用程序上实现.我想将字符串上的int元素分别推送到向量中.我怎么能够?
#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
}
Run Code Online (Sandbox Code Playgroud)