6/21/2018

String split by delimiter (c++/c)

refer to souce code

...
void CForeAndBack::getStrings(string csvFname, vector<string> eachStr, string delimiter)
{
    //parsing
    size_t pos = 0;
    while ((pos = csvFname.find(delimiter)) != std::string::npos) {
        string token = csvFname.substr(0, pos);
        std::cout << token << std::endl;
        eachStr.push_back(token);
        csvFname.erase(0, pos + delimiter.length());
    }
    std::cout << csvFname << std::endl;
    eachStr.push_back(csvFname);
}
...


No comments:

Post a Comment