Click to See Complete Forum and Search --> : cin >> buf endless loop


ccfriend
October 7th, 2005, 04:38 PM
Hi

I have the code


#include<iostream>
using namespace std;

int main()
{
string buf;

while( cin >> buf )
{
cout << buf;

//do some process in buf
}
//end the loop someway

cout << "The result";

return 0;
}



With what keyboard shortcut I can end the loop in order to proceed in my program ( I am not interested in signal solution or


if ( buf == "END" )
break;


Thanks

SuperKoko
October 7th, 2005, 04:45 PM
You can send the EOF character with CONTROL+Z, but it may behaves strangely (and need two CTRL+Z in some cases).

Eli Gassert
October 7th, 2005, 05:54 PM
I believe ctrl+c or ctrl+d, and look for the .fail() function check the fail bit. I can't remember for sure, though, sorry.

SuperKoko
October 8th, 2005, 04:03 AM
CTRL+C terminates the process, with memory leaks and all the bad effects.