Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Is dere any way to pause a for loop in between a program (http://www.go4expert.com/forums/dere-pause-loop-program-t19135/)

amanbaua 23Aug2009 13:33

Is dere any way to pause a for loop in between a program
 
Can u plzz help me out of dis prob of pausing a for loop

shabbir 23Aug2009 14:16

Re: Is dere any way to pause a for loop in between a program
 
Use break statement

mayjune 23Aug2009 14:52

Re: Is dere any way to pause a for loop in between a program
 
What do you mean pausing a loop? If you want to get out of it, then what shabbir said will work.
If not, please post the question properly..

c_user 23Aug2009 14:58

Re: Is dere any way to pause a for loop in between a program
 
you can use exit(0) or if it is an infinite loop use the keys ctrl+c to terminate any .exe file..
have a good day

mayjune 23Aug2009 15:01

Re: Is dere any way to pause a for loop in between a program
 
He wants to pause c_user, not exit the program..

c_user 23Aug2009 15:08

Re: Is dere any way to pause a for loop in between a program
 
mayjune i think by the use of break we will be "out" of the loop and not "pause"...acc. to my knowledge.

can u please specify me whether i m right or not?

mayjune 23Aug2009 15:21

Re: Is dere any way to pause a for loop in between a program
 
You are right, it will get him out of the loop, but then exit function wont pause it either. Would it?
I think we all are not sure what he means by pausing a loop in between a program. Let him reply by what he implies...and whatever he means he can do it :)

c_user 23Aug2009 15:26

Re: Is dere any way to pause a for loop in between a program
 
yes you are right mayjune....
he have to be specific so as to get the appropriate answer....:-).

amanbaua 25Aug2009 18:39

Re: Is dere any way to pause a for loop in between a program
 
ye may june i m in search of pausing a for loop
the break and exit statements make the control get out of the loop
i hav just made a graphics using c program in which if th for loop is paused for a moment my program will work
so is i possi ble my friends dat a for loop can be paused?????

SaswatPadhi 25Aug2009 18:51

Re: Is dere any way to pause a for loop in between a program
 
So, you want a delay in your loop ... "pause" diverted all of us to something different.

Anyway, you can do it like this :

For TurboC++ ::
Code:

#include <dos.h>
.
.
.
for(...)
{
    .
    .
    delay(x); // This will put a delay of x milliseconds
    .
    .

}

For ANSI C++ ::
Code:

#include <windows.h>
.
.
.
for(...)
{
    .
    .
    Sleep(x); // This will put a delay of x milliseconds
    .
    .

}



All times are GMT +5.5. The time now is 03:34.