How to split a string in C++ using STL ?
What's the most elegant way to split a string in C++? The string can be assumed to be composed of words separated by whitespace.
Here’s a way to extract tokens from an input string, relying only on Standard Library facilities. It’s an example of the power and elegance behind the design of the STL.
Instead of copying the extracted tokens to an output stream, one could insert them into a container, using the same generic copy algorithm.
Original link:https://stackoverflow.com/questions/236129
Author Question: https://stackoverflow.com/users/1630
Author Anwser: https://stackoverflow.com/users/30767
If you found this post or this website helpful and would like to support our work, please consider making a donation. Thank you!
Help Us