I have a std::string with multiple lines and I need to read it line by line. Please show me how to do it with a small example.
std::string
Ex: I have a string string h;
string h;
h will be:
Hello there. How are you today? I am fine, thank you.
I need to extract Hello there., How are you today?, and I am fine, thank you. somehow.
Hello there.
How are you today?
I am fine, thank you.
#include <sstream> #include <iostream> int main() { std::istringstream f("line1 line2 line3"); std::string line; while (std::getline(f, line)) { std::cout << line << std::endl; } }
1.4m articles
1.4m replys
5 comments
57.0k users