return to the beginning (restart)

This is a discussion on return to the beginning (restart) within the C++ Programming forums, part of the General Programming Boards category; how do you restart?? ( to the beginning of the code) i tried with: Code: return 1; but dindt work ...

  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    70

    Question return to the beginning (restart)

    how do you restart?? ( to the beginning of the code)

    i tried with:
    Code:
     return 1;
    but dindt work

    PS: i am working in a main function and repeating by main(); is illigal
    ( i dont know why but everbody tells me that)

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >how do you restart?? ( to the beginning of the code)
    Wrap the whole of your program in a loop:
    Code:
    int main()
    {
      bool done = false;
    
      while ( !done ) {
        // Program logic
      }
    }
    >i dont know why but everbody tells me that
    The main function can't be called recursively in C++. It's a rule set by the language standard, though several compilers will allow it for backward compatibility with C and non-standard C++.
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    70
    one problem in my main function there is already a loop
    and if i am just , you can put an loop in a loop??

    but thnx for the answer

  4. #4
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,452
    yes - you can

    or you can build another function move there the "Program logic" part and get the simple main function like the suggested above
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  5. #5
    Registered User
    Join Date
    Sep 2006
    Posts
    70
    srry was wrong just tested and it woks

  6. #6
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    You could use some tutorials. You are missing some basics of C++.

    Try some on this site. (www.cprogramming.com)
    "The Internet treats censorship as damage and routes around it." - John Gilmore

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to combine these working parts??
    By transgalactic2 in forum C Programming
    Replies: 0
    Last Post: 02-01-2009, 07:19 AM
  2. Why only 32x32? (OpenGL) [Please help]
    By Queatrix in forum Game Programming
    Replies: 2
    Last Post: 01-23-2006, 01:39 PM
  3. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  4. sort linked list using BST
    By Micko in forum C Programming
    Replies: 8
    Last Post: 10-04-2004, 02:04 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 09:01 PM

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