J
JackC
Hi,
How do i use stringstreams getline function to extract lines from an
existing string?
Say i have: string strlist = "line1\r\nLine2\r\nLine3\r\n";
I want to extract each line out into a vector array of strings, but i
cant get stringstream working
This is the sort of code i have tried:
// istream& getline (char* s, streamsize n )
stringstream MyStream;
MyStream<<strlist;
string extracted_line = MyStream.getline(mystring, 0);
Clearly thats very wrong, but im not sure how to correctly use
getline()? Also how would i loop this up so it extracts all the lines
in the string? Would my condtion just be checking extracted_line !=
std::string::npos?
Thanks for any help,
Jack
How do i use stringstreams getline function to extract lines from an
existing string?
Say i have: string strlist = "line1\r\nLine2\r\nLine3\r\n";
I want to extract each line out into a vector array of strings, but i
cant get stringstream working
This is the sort of code i have tried:
// istream& getline (char* s, streamsize n )
stringstream MyStream;
MyStream<<strlist;
string extracted_line = MyStream.getline(mystring, 0);
Clearly thats very wrong, but im not sure how to correctly use
getline()? Also how would i loop this up so it extracts all the lines
in the string? Would my condtion just be checking extracted_line !=
std::string::npos?
Thanks for any help,
Jack