#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
Related Posts:
- How do I tokenize a string in C++?
- Reading getline from cin into a stringstream (C++)
- Split a string into an array in C++
- Incomplete type is not allowed: stringstream
- How do you clear a stringstream variable?
- Linker Error C++ “undefined reference ” [duplicate]
- convert a char* to std::string
- system(“pause”); – Why is it wrong?
- C++ equivalent of Java’s toString?
- Is there any built-in factorial function in c++?
- C++ struct constructor
- When to use virtual destructors?
- std::string to float or double
- What is difference between Application Buffer and System Buffer
- C++ undefined reference to defined function
- How do I include the string header?
- How to navigate through a vector using iterators? (C++)
- Differences between C++ string == and compare()?
- What does the explicit keyword mean?
- program ended prematurely and may have crashed. exit code 0xc0000005
- How to use _CRT_SECURE_NO_WARNINGS
- Stack Memory vs Heap Memory
- Is it more efficient to copy a vector by reserving and copying, or by creating and swapping? [duplicate]
- C++ Singleton design pattern
- C++ Linked List Node with class
- ‘was not declared in this scope’ error
- What is the difference between const int*, const int * const, and int const *?
- How to convert a single char into an int [duplicate]
- Exception Handling in C++ Terminate called after throwing an instance of ‘char const*’
- Using O_RDWR vs O_RDONLY | O_WRONLY
- How to implement the factory method pattern in C++ correctly
- c++ array – expression must have a constant value
- getline() does not work if used after some inputs
- Passing a 2D array to a C++ function
- ‘typeid’ versus ‘typeof’ in C++
- Fatal error: iostream: No such file or directory in compiling C program using GCC
- Thread pooling in C++11
- Callback functions in C++
- Reading from text file until EOF repeats last line
- How does std::forward work? [duplicate]
- Examples of good gotos in C or C++
- Sleep function in C++
- Undefined reference to class constructor, including .cpp file fixes
- Deleting a dynamically allocated 2D array
- How to add element to C++ array?
- Difference of keywords ‘typename’ and ‘class’ in templates?
- Error: Jump to case label in switch statement
- What does int & mean
- splitting a string into an array in C++ without using vector
- Remove spaces from std::string in C++
- How to use glOrtho() in OpenGL?
- error: ‘ostream’ does not name a type
- Remove spaces from std::string in C++
- Read data from a file into an array – C++
- Unknown override specifier, missing type specifier
- What is the preferred way to include error messages in C++?
- How to Convert a C++ String to Uppercase
- C++ Fractions Class
- #pragma once vs include guards?
- Debug vs Release in CMake
- C++ Remove punctuation from String
- prototype for “….” does not match any in class “…”
- Cannot open Windows.h in Microsoft Visual Studio
- Nested For – Loops to create multiplication table C++
- Reference to non-static member function must be called
- Call to non-static member function without an object argument compiler error
- How can I assign an array from an initializer list?
- I get this error: “glibc detected”
- How can I get and use the header file
in my C++ program? - cin.eof() functionality
- Implementing a tree in C++
- Drawing Circle with OpenGL
- Run-Time Check Failure #2 – Stack around the variable ‘foo’ was corrupted
- How to implement “Press Any Key To Exit”
- Reading and writing binary file
- got “cannot appear in a constant-expression” when using template
- C++ ostream and ofstream conversions
- C++ discards qualifiers
- What is the source of the data for the ProgramFiles, ProgramW6432Dir, ProgramFilesDir (x86), CommonProgramFiles environment variables?
- C++ : Exception occurred in script: basic_string::_S_construct NULL not valid
- Xcode 11.1: iostream’ file not found
- non-member function cannot have cv-qualifier
- too many initializers for ‘int [0]’ c++
- function does not take 1 arguments c++
- overloaded function with no contextual type information
- How exactly do lookup tables work and how to implement them?
- How do I simply compare characters in C++?
- How to Check the Version of my gcc?
- Difference between function arguments declared with & and * in C++
- C++ floating point to integer type conversions
- How to get an average in C++?
- C++: variable ‘std::ifstream ifs’ has initializer but incomplete type
- template argument 1 is invalid (Code::Blocks Win Vista) – i don’t use templates
- invalid use of template name without an argument list
- What is “error C2061: syntax error : identifier “?
- What is the size of sizeof(vector)? C++
- C++ – Print Out Objects From Set
- Why virtual & static keywords aren’t allowed outside class declaration?
- C++ equivalent of java’s instanceof
- Conversion from ‘myItem*’ to non-scalar type ‘myItem’ requested