|
-
October 7th, 2005, 04:38 PM
#1
cin >> buf endless loop
Hi
I have the code
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
Code:
if ( buf == "END" )
break;
Thanks
-
October 7th, 2005, 04:45 PM
#2
Re: cin >> buf endless loop
You can send the EOF character with CONTROL+Z, but it may behaves strangely (and need two CTRL+Z in some cases).
"inherit to be reused by code that uses the base class, not to reuse base class code", Sutter and Alexandrescu, C++ Coding Standards.
Club of lovers of the C++ typecasts cute syntax: Only recorded member.
Out of memory happens! Handle it properly!
Say no to g_new()!
-
October 7th, 2005, 05:54 PM
#3
Re: cin >> buf endless loop
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.
-
October 8th, 2005, 04:03 AM
#4
Re: cin >> buf endless loop
CTRL+C terminates the process, with memory leaks and all the bad effects.
"inherit to be reused by code that uses the base class, not to reuse base class code", Sutter and Alexandrescu, C++ Coding Standards.
Club of lovers of the C++ typecasts cute syntax: Only recorded member.
Out of memory happens! Handle it properly!
Say no to g_new()!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|