I am quite new to C++ and i think i made a tiny mistake somewhere in this bit of code. I failed to spot it so far. I hope you can help me, and tell me how/where/why it is wrong? Many thanks in advance.
The code:
std::vector<std::string> spliter(const std::string& s, char delimiter)
{
std::vector<std::string> result;
size_t start = 0;
for(std::size_t i = 0; i != std::string::npos; i = s.find(delimiter,start))
{
result.push_back( s.substr(start,i-start) );
start = i+1;
}
iprintf("\x1b[2J");
printf("\x1b[4;0HDone Splitting Text.");
swiWaitForVBlank();
return result;
}
Parameters given:
s = "$ 00-000 SS ''Prologue'' CF N00-001 V 1 MP 20"
delimiter = ' '
(a space)
Expected result:
result[0] = $
result[1] = 00-000
result[2] = SS
etc.
Current wrong result:
result[0] =
result[1] =
result[2] = 00-000
etc.
Any help is greatly appreciated!