2.4.5 Creating an Input Stream from a String
String Input Stream
#include <sstream>string line;
istringstream iss(line);Three-Argument `getline` Call
string line;
getline(cin, line); //(input stream, destination)string token;
char delimiter = ' '; // if you want to use a space character as a delimiiter
getline(cin, token, delimiter);string line;
istringstream iss(line);
string token;
while (getline(iss, token, ';')) // assuming you want to use ; as a delimiter
{
// read from the string
}Try This Example
Last updated