Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   breaking the loop (http://www.go4expert.com/forums/breaking-the-loop-t6991/)

vaibhav_89 24Oct2007 09:12

breaking the loop
 
which function can i use in c/c++ so that as soon as i press a certain character then the loop breaks away goes into the next loop.
for example:
start:
Code:

for(..;..;..;) /*loop1*/
{....;
.....; /*now if i press any 'a' when loop 1 is excuting then it should go to loop 2
.....;
}
goto strat;
if(getch()=='a') /* loop 2*/
for (..;..;..)
...;
...;
..;


shabbir 24Oct2007 09:32

Re: breaking the loop
 
If you want the loop to break immediately its not about having an input mechanism but it should be done on different thread.

Something like when a loop is executed it checks of some variable and that variable is set via different thread which is meant for the input and thats the only way of doing it. If you have the input mechanism in the loop itself it will not proceed further till you input the value.

vaibhav_89 24Oct2007 09:36

Re: breaking the loop
 
i want to run the loop till a character 'a' is inputted.as soon as 'a' is typed i want the previous loop to break up and go to a new loop
for example:
start:
Code:

for(..;..;..;) /*loop1*/
{....;
.....; /*now if i press any 'a' when loop 1 is excuting then it should go to loop 2
.....;
}
goto strat;
/*loop 2 should strat if 'a' is typed when loop 1 is running*/
if(getch()=='a') /* loop 2*/
for (..;..;..)
...;
...;
..;


vaibhav_89 24Oct2007 09:42

Re: breaking the loop
 
i want to run the loop till a character 'a' is inputted.as soon as 'a' is typed i want the previous loop to break up and go to a new loop
for example:
start:
Code:

for(..;..;..;) /*loop1*/
{....;
.....; /*now if i press any 'a' when loop 1 is excuting then it should go to loop 2
.....;
}
goto strat;
/*loop 2 should strat if 'a' is typed when loop 1 is running*/
if(getch()=='a') /* loop 2*/
for (..;..;..)
...;
...;
..;


shabbir 24Oct2007 10:05

Re: breaking the loop
 
Do you read the replies or just copy paste the same thing over and over again.

shabbir 24Oct2007 10:07

Re: breaking the loop
 
Now its 5 times you have that smiley post where you did not read the reply as well.


All times are GMT +5.5. The time now is 15:49.