相关疑难解决方法(0)

Int tokenizer

我知道有字符串标记符,但是有"int tokenizer"吗?

例如,我想拆分字符串"12 34 46"并具有:

列表[0] = 12

列表[1] = 34

列表[2] = 46

特别是,我想知道Boost :: Tokenizer是否这样做.虽然我找不到任何不使用字符串的示例.

c++ tokenize

15
推荐指数
2
解决办法
3029
查看次数

从string到stringstream到vector <int>

我有一个步骤的示例程序,我想在我的应用程序上实现.我想将字符串上的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)

c++ string vector stringstream

6
推荐指数
2
解决办法
3万
查看次数

标签 统计

c++ ×2

string ×1

stringstream ×1

tokenize ×1

vector ×1