C++11文字列分割
Using explode function as it used in PHP programming. The code above just a simple function, yet well-tested with various case. Following is the example in main function:
Edit & Run
will produces output:
int main()
{
string str{"the quick brown fox jumps over the lazy dog"};
vector v{explode(str, ' ')};
for(auto n:v)
cout << n << endl;
return 0;
}
Edit & Run
will produces output:
the
quick
brown
fox