jeudi 27 septembre 2018

C++: split a string and get all non-empty elements

Now I have a C++ string like this

string str = "         1     30716         5         5         2         2         6";

I need to split the string and get all non-empty elements1,30716,5,5,2,2,2and6. How can I do this?
By the way, someone just told me that C# can do this easily by using string.Split(separator,StringSplitOptions.RemoveEmptyEntries).Can I do the same thing in C++?

Aucun commentaire:

Enregistrer un commentaire