GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 30-Dec-2007, 14:06
memmudu memmudu is offline
New Member
 
Join Date: Dec 2007
Posts: 2
memmudu is on a distinguished road

Exiting an infinite loop.


below you see a simple infinite loop.
I want to run the code inside the loop n seconds and after n seconds I will hit ctrl-z so that the loop terminates.
I dont want to type any other character to run the loop. It will loop infinite times until I enter ctrl-z


CPP / C++ / C Code:
while (true)
	 {
   	 int a=hillclimbing(citylist,distance);
	 if (a<min)
		 min=a;
	 k++;
	 } 
  #2  
Old 31-Dec-2007, 07:25
cup cup is offline
New Member
 
Join Date: Feb 2006
Posts: 15
cup will become famous soon enough

Re: please help me exiting an infinite loop...


It depends on which system you are using. In Windows, they have something called called kbhit which will tell you when you hit a character. Unix is a bit more difficult. You may have to play with some ioctl things.
 
 

Recent GIDBlogAccepted for Ph.D. program by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
infinite loop!!! cool C Programming Language 2 13-Aug-2007 15:59
breaking an infinite loop through stdin pisuke C Programming Language 9 03-Jul-2007 21:19
Text-Based Roulette Game mfm1983 C++ Forum 5 29-Nov-2006 13:20
C++ Aparently on infinite loop, but where? Link C++ Forum 7 08-Sep-2006 09:40
Array 1 dimensional help please asap lion123 C Programming Language 10 18-Feb-2005 22:53

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 13:31.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.