Thread: return to the beginning (restart)

  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,897
    >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
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    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
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  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, 08:19 AM
  2. Why only 32x32? (OpenGL) [Please help]
    By Queatrix in forum Game Programming
    Replies: 2
    Last Post: 01-23-2006, 02: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, 10:01 PM