Thread: About running a program

  1. #1
    Yiannis
    Guest

    Unhappy About running a program

    Hello!!!This is my first time getting in this site,so i'm glad my queries can be answered.
    Well...
    After making a program of simulating 'keywords' of DOS to C, and given that its structure is right, how can I make the program run as many times the user wants,by returning every time to the begining without ending?
    Thanks!!!

  2. #2
    Registered User Draco's Avatar
    Join Date
    Apr 2002
    Posts
    463
    All you would need to do is to put the program in a for loop that keeps repeating itself until the user enters something, escape for example.


    Code:
    /*the loop always initializes, and at the end of the loop it asks for a key.  If the user presses escape the loop ends*/
    char check;
    for( ;check!='ESC';getch(check) )
    {
     /*put your code here*/
    }

  3. #3
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,164
    Originally posted by Draco
    All you would need to do is to put the program in a for loop that keeps repeating itself until the user enters something, escape for example.


    Code:
    /*the loop always initializes, and at the end of the loop it asks for a key.  
       If the user presses escape the loop ends*/
    char check;
    for( ;check!='ESC';getch(check) )
    {
     /*put your code here*/
    }
    A while or do...while loop is tailor made for this, whereas a for loop is best used when a known number of iterations are needed. The for works, it's just not an optimum answer.
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program running long
    By smarta_982002 in forum Windows Programming
    Replies: 3
    Last Post: 03-27-2008, 05:24 AM
  2. Running my program in the background
    By shoobsie in forum Windows Programming
    Replies: 4
    Last Post: 10-09-2005, 02:38 AM
  3. Replies: 3
    Last Post: 09-05-2005, 08:57 AM
  4. Why is my program running away?
    By badkitty in forum C++ Programming
    Replies: 4
    Last Post: 09-19-2001, 04:27 PM
  5. Running program
    By muffin in forum C Programming
    Replies: 5
    Last Post: 08-30-2001, 10:57 AM