return to main or restart program

This is a discussion on return to main or restart program within the C Programming forums, part of the General Programming Boards category; hi, can I call main() in other function. if so how?! I need to go back and start again my ...

  1. #1
    Registered User
    Join Date
    May 2008
    Location
    IR, Iran
    Posts
    103

    return to main or restart program

    hi,

    can I call main() in other function. if so how?!

    I need to go back and start again my program tell me how can I do this

    thanks alot

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,668
    Quote Originally Posted by behzad_shabani View Post
    can I call main() in other function. if so how?!
    You should not.

    I need to go back and start again my program tell me how can I do this
    Use a loop.
    And use your creativity.
    It's not difficult to imagine a way.

    If another function has the need to return the the beginning of a program, it could return something that tells main it wants to go back to the beginning, for example.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    May 2008
    Location
    IR, Iran
    Posts
    103
    Quote Originally Posted by Elysia View Post
    Use a loop.
    you mean to use "loop:" and "goto"?

    If another function has the need to return the the beginning of a program, it could return something that tells main it wants to go back to the beginning, for example.
    can you tell me more

  4. #4
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,668
    Quote Originally Posted by behzad_shabani View Post
    you mean to use "loop:" and "goto"?
    No! Goto is the tool of the devil!
    Goto is NOT the only way to loop. C has three ways.

    can you tell me more
    I suggest you get a book or tutorial and learn these concepts and you should find how pretty quickly.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Quote Originally Posted by behzad_shabani View Post
    you mean to use "loop:" and "goto"?
    If you're serious, you need to get back to the books. Actually, no, you have to get back to the books even if you're joking.

    Quote Originally Posted by behzad_shabani View Post
    can you tell me more
    Code:
    ...
    
    int main(void)
    {
        int continue;
        while((continue = runProgram()));
        return 0;
    }
    
    ...
    runProgram() would contain your program.

  6. #6
    Registered User
    Join Date
    May 2008
    Location
    IR, Iran
    Posts
    103
    thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. New string functions
    By Elysia in forum C Programming
    Replies: 11
    Last Post: 03-28-2009, 05:03 AM
  2. Replies: 5
    Last Post: 03-05-2009, 10:32 AM
  3. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 09:42 PM
  4. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  5. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 10:14 PM

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