Skip to main content
Using `std::` qualifiers, using the string OP mentioned in the question
Source Link
einpoklum
  • 126.7k
  • 69
  • 385
  • 793

Another quick way is to use getline. Something like:

stringstreamstd::istringstream ssiss("bla bla"str);
std::string s;

while (std::getline(ssiss, s, ' ')) {
  std::cout << s << std::endl;
}

If you want, you can make a simple split() method returning a std::vector<string>, which is really really useful.

Another quick way is to use getline. Something like:

stringstream ss("bla bla");
string s;

while (getline(ss, s, ' ')) {
 cout << s << endl;
}

If you want, you can make a simple split() method returning a vector<string>, which is really useful.

Another quick way is to use getline. Something like:

std::istringstream iss(str);
std::string s;

while (std::getline(iss, s, ' ')) {
  std::cout << s << std::endl;
}

If you want, you can make a simple split() method returning a std::vector<string>, which is really useful.

Bounty Ended with 50 reputation awarded by CommunityBot
added 25 characters in body
Source Link
Dominic Rodger
  • 99.2k
  • 36
  • 201
  • 216

Another quick way is to use getline.getline. somethingSomething like:

stringstream ss("bla bla"); string s;

while (getline(ss, s, ' ')) { cout << s << endl; }

stringstream ss("bla bla");
string s;

while (getline(ss, s, ' ')) {
 cout << s << endl;
}

ifIf you want, you can make a simple split()split() method returning a vector of stringvector<string>, which is really useful.

Another quick way is to use getline.. something like:

stringstream ss("bla bla"); string s;

while (getline(ss, s, ' ')) { cout << s << endl; }

if you want, you can make a simple split() method returning a vector of string, which is really useful.

Another quick way is to use getline. Something like:

stringstream ss("bla bla");
string s;

while (getline(ss, s, ' ')) {
 cout << s << endl;
}

If you want, you can make a simple split() method returning a vector<string>, which is really useful.

Source Link
user35978
  • 2.4k
  • 1
  • 13
  • 14

Another quick way is to use getline.. something like:

stringstream ss("bla bla"); string s;

while (getline(ss, s, ' ')) { cout << s << endl; }

if you want, you can make a simple split() method returning a vector of string, which is really useful.