getline

When using the getline function, what do I need to do to to get line 1 and then again to get line 2?
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.
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())

?
?
?
Lines 4 and 5 of the snippet I posted, change cin to infile.
Topic archived. No new replies allowed.