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 (..;..;..) ...; ...; ..;
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.
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 (..;..;..) ...; ...; ..;
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 (..;..;..) ...; ...; ..;