the code is encompleted :(
only the tabs and empty spaces must be ignored, but '&' must be added splitted too.
so what you can advice me more?
(i don't understand the while code :( )
#include <iostream>
#include <string>
#include <vector>
void split( const std::string &s, std::vector<std::string> &result, std::string dividers )
{
int p = 0, q;
while ( p < s.size() )
{
q = s.find_first_of( dividers, p );
if ( q == std::string::npos ) break;
if ( q != p ) result.push_back( s.substr( p, q - p ) );
p = q + 1;
}
if ( p < s.size() ) result.push_back( s.substr( p ) );
}
int main()
{
std::string dividers = " \t()"; // put what you like here
std::string test = "And Quiet Flows the Don(Mikhail\tSholokhov)";
std::vector<std::string> phrases;
split( test, phrases, dividers );
for ( std::string s : phrases ) std::cout << s << '\n';
}