Going back to the beginning

This is a discussion on Going back to the beginning within the C++ Programming forums, part of the General Programming Boards category; Does anybody know how to make a program go back to the beginning after it has completed its operations? Thanks ...

  1. #1
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052

    Thumbs up Going back to the beginning

    Does anybody know how to make a program go back to the beginning after it has completed its operations?

    Thanks
    -Chris

  2. #2
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    You could use a while or a do...while loop to loop back to the beginning. For example:

    Code:
    #include <iostream>
    
    int main()
    {
        char quit;
        do
        {
            // Call functions, declare variables, do work, etc.
            std::cin >> quit;
        } while(quit != 'y' && quit != 'Y');
        return 0;
    }
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  3. #3
    Registered User CumQuaT's Avatar
    Join Date
    Sep 2001
    Posts
    73

    Talking Replying (or trying to reply!)

    I'm no C++ expert, but try using the RUB command.

    I'm not 100% sure but it's worth a try!
    Why? The often unanswerable question. If it is unanswerable, why answer it?

    Join the Cult of Sheograth, it's the place to be!

    http://cultosheogorath.proboards16.com

    Lord, we know what we are, yet we know not what we may be... Who wrote that anyway? If you know, E-Mail me. mr_shnokovitz@yahoo.com

    Joy to all the fishes...

    **infected by frenchfry164**

  4. #4
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    is it possible to do this without having to ask them to input a "y"?

  5. #5
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Yeah, you can implement that part however you want. I was just trying to demonstrate the use of a loop to go back to the beginning of the program. For example, the following code would keep running until it was shut down by a call to exit(1) or something similar somewhere in your code:

    Code:
    int main()
    {
        while(1)
        {
            // All code, function calls, etc. to run the program.
        }
        return 0;
    }
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  6. #6
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    Thanks, that works really well.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. "if you love someone" :D
    By Carlos in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 10-02-2003, 02:10 AM
  2. UInt to CString and back
    By xlnk in forum Windows Programming
    Replies: 6
    Last Post: 08-27-2003, 04:08 PM
  3. Some woman back ended my car today, and back hurts
    By Terrance in forum A Brief History of Cprogramming.com
    Replies: 19
    Last Post: 08-20-2003, 01:42 AM
  4. Returning a Tree node back to void main()
    By gazza in forum C++ Programming
    Replies: 2
    Last Post: 07-07-2002, 03:48 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21