This is my split function:
std::vector<std::string> split(std::string& s, const char delimiter, bool ignore_empty = false){
std::vector<std::string> result;
std::string tmp = s;
while(tmp.find(delimiter) != std::string::npos) {
std::string new_part = tmp.substr(0, tmp.find(delimiter));
tmp = tmp.substr(tmp.find(delimiter)+1, tmp.size());
if(not (ignore_empty and new_part.empty())) {
result.push_back(new_part);
}
}
if(not (ignore_empty and tmp.empty())){
result.push_back(tmp);
}
return result; }
I'm calling the split function like this:
vector<std::string> tiedot = split(line, ";", true);
Where the line is: S-Market;Hervantakeskus;sausage;3.25
I need to split the string to strings and add them to a vector but I get this
Error: Invalid conversion from const char * to char
Do you know how to fix this?