getline

Sep 13, 2016 at 6:07pm
When using the getline function, what do I need to do to to get line 1 and then again to get line 2?
Sep 13, 2016 at 6:44pm
From where?

Assuming cin:
1
2
3
4
5
  string line1; 
  string line2;

  getline (cin, line1);
  getline (cin, line2);


It doesn't get much simpler.
Sep 13, 2016 at 6:56pm
If I'm reading in a file with two lines.

string filename;

cout << "Enter filename: "
cin >> filename;
cout << filename << endl;

infile.open(filename.c_str())

?
?
?
Sep 13, 2016 at 7:23pm
Lines 4 and 5 of the snippet I posted, change cin to infile.
Topic archived. No new replies allowed.