#include <iostream>
#include <sstream>
std::string input = "abc,def,ghi";
std::istringstream ss(input);
std::string token;
while(std::getline(ss, token, ',')) {
std::cout << token << '\n';
}
abc
def
ghi
More Related Contents:
- How do I tokenize a string in C++?
- How to test whether stringstream operator>> has parsed a bad type and skip it
- How do you clear a stringstream variable?
- Why copying stringstream is not allowed?
- Parse (split) a string in C++ using string delimiter (standard C++)
- Why does stringstream >> change value of target on failure?
- How do I check if a C++ string is an int?
- How to clear stringstream? [duplicate]
- stringstream, string, and char* conversion confusion
- How to read file content into istringstream?
- C++ Templates Angle Brackets Pitfall – What is the C++11 fix?
- how copy from one stringstream object to another in C++?
- C++ Extract number from the middle of a string
- What’s the difference between istringstream, ostringstream and stringstream? / Why not use stringstream in every case?
- Why was std::strstream deprecated?
- Need help on C programming -> pointer
- Is there a difference between copy initialization and direct initialization?
- Best practices for circular shift (rotate) operations in C++
- C/C++: Force Bit Field Order and Alignment
- What is this smiley-with-beard expression: “”?
- Representing big numbers in source code for readability?
- opencv multi channel element access
- Why is there no support for concatenating std::string and std::string_view?
- Efficiency of the STL priority_queue
- How to release pointer from boost::shared_ptr?
- Clarification needed regarding getchar() and newline
- Template instantiation details of GCC and MS compilers
- How do I call the original “operator new” if I have overloaded it?
- Writing function definition in header files in C++
- Difference between string.h and cstring?