end of input getline
c++, getline, input
Solution
If you want input to end on an empty line then you have to test for it. For instance.
string *line = new string[100];
int counter = 0;
while (getline(cin, line[counter]) && line[counter].size() > 0)
{
counter++;
}
Congrats for using `getline()` correctly BTW. Unlike some of the answers you've been given.
Problem
Possible Duplicate: Why doesn’t getchar() recognise return as EOF in windows console? I have a simple problem... Lets say I want to read lines from standart input as long as there is something, but I dont know how many lines it will be. For example I am doing school work and input is ``` a ababa bb cc ba bb ca cb ``` I dont know exactly how many lines it will be, so I tried ``` string *line = new string[100]; int counter = 0; while(getline(cin,line[counter])) { counter++; } ``` But it doesn't work... thanks for help.