0

My code is working except for one problem, when I run it it doesn't seem to return the first string.

    string text;
    cin >> text;
    getline(cin ,text);
    istringstream  iss(text);
    copy(istream_iterator<string>(iss),
            istream_iterator<string>(),
            ostream_iterator<string>(cout, "\n"));

So if my input was, bf "ing" filename, it will only output:

"ing" 
filename

I want it so it can output the whole line like so:

bf 
"ing"
filename
Mat
  • 202,337
  • 40
  • 393
  • 406
user2757849
  • 227
  • 3
  • 4
  • 14

2 Answers2

0

Get rid of

cin >> text; .

That one consumes the first word of your input, reads it into text, and then you discard it by overwriting text in the next line.

us2012
  • 16,083
  • 3
  • 46
  • 62
0

Assuming you want to have the entire line printed from parsing the string passed to std::istringstream you should remove first reading a separate word, i.e., remove the line

cin >> text;
Dietmar Kühl
  • 150,225
  • 13
  • 225
  • 380