Is dere any way to pause a for loop in between a program

Discussion in 'C' started by amanbaua, Aug 23, 2009.

  1. amanbaua

    amanbaua New Member

    Joined:
    Aug 23, 2009
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Can u plzz help me out of dis prob of pausing a for loop
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Use break statement
     
  3. mayjune

    mayjune New Member

    Joined:
    Jun 14, 2009
    Messages:
    814
    Likes Received:
    33
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Pune,Delhi
    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..
     
  4. c_user

    c_user New Member

    Joined:
    Aug 23, 2009
    Messages:
    86
    Likes Received:
    8
    Trophy Points:
    0
    Occupation:
    Php dev
    Location:
    Bhubaneswar
    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
     
  5. mayjune

    mayjune New Member

    Joined:
    Jun 14, 2009
    Messages:
    814
    Likes Received:
    33
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Pune,Delhi
    He wants to pause c_user, not exit the program..
     
  6. c_user

    c_user New Member

    Joined:
    Aug 23, 2009
    Messages:
    86
    Likes Received:
    8
    Trophy Points:
    0
    Occupation:
    Php dev
    Location:
    Bhubaneswar
    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?
     
  7. mayjune

    mayjune New Member

    Joined:
    Jun 14, 2009
    Messages:
    814
    Likes Received:
    33
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Pune,Delhi
    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 :)
     
  8. c_user

    c_user New Member

    Joined:
    Aug 23, 2009
    Messages:
    86
    Likes Received:
    8
    Trophy Points:
    0
    Occupation:
    Php dev
    Location:
    Bhubaneswar
    yes you are right mayjune....
    he have to be specific so as to get the appropriate answer....:).
     
  9. amanbaua

    amanbaua New Member

    Joined:
    Aug 23, 2009
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    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?????
     
  10. SaswatPadhi

    SaswatPadhi ~ Б0ЯИ Τ0 С0δЭ ~

    Joined:
    May 5, 2009
    Messages:
    1,342
    Likes Received:
    55
    Trophy Points:
    0
    Occupation:
    STUDENT !
    Location:
    Orissa, INDIA
    Home Page:
    http://www.crackingforfun.blogspot.com
    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
        .
        .
    
    }
    
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice