I need to make a program in c ++ that reads a multi-line input and stores each line (string) in a vector.
I've already tried using cin.eof()
and fgets()
but it did not work.
#include<iostream>
#include<string>
using namespace std;
int main()
{
string entrada;
cin >> entrada;
while(!cin.eof())
{
cout << "Entrada ainda não terminou." << endl;
cin.ignore();
getline(cin, entrada);
cout << entrada << endl;
}
cout << "Entrada terminou." << endl;
return 0;
}
Can anyone help?