So I've been pulling my hair out about this since yesterday, I've checked multiple posts on here trying to figure this out, basically, I'm trying to read 1 or more lines from standard input into a string variable then use an istringstream to get integer values. This is what i have:
string line;
int num;
while(getline(cin, line)){
istringstream data(line);
while(data >> num){
do stuff...
}
}
However, the outer loop never exits, if there is no input in the standard input it just sits there waiting and never actually exits the loop, so the program basically pauses until something is entered, and then just continues the loop once more. Can someone tell me why getline doesn't just cause an exit condition when there is nothing on stdin, and can someone help me to fix this issue, your help will be greatly appreciated.