0

I have a basic_string of text. There are always 5 words on the line separated by |. I have made that string into a istringstream and i have tried this:

istringstream MyStream(line_of_text);
char cDelim;
basic_string a,b,c,d,e;

MyStream>>a>>cDelim>>b>>cDelim>>c>>cDelim>>d>>cDelim>>e ;

Does not work. "a" contains the whole string, b,c,d,e are blank. I need to figure out how to tell it that | is the delimeter. Is it possible to do this using insertion operators, or do I need to walk the string, one character at a time and look for the | ?

thanks Fred Emmerich

  • This question is NOT like the one referenced because mine specifically asks about insertion operators on memory streams and not related to get_line(). I did see the other question but I want to venture into the insertion operator end of things. That was why I asked the question this way. –  May 18 '20 at 15:50
  • What is the _insertion operator_? If you mean `operator>>` then no, it's not possible. Please elaborate the differences to the dupe because it also looks like the dupe answers your question. – Thomas Sablik May 18 '20 at 16:20
  • I have done this: –  May 19 '20 at 17:20

0 Answers0