Thread: main() return values and exit()

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912

    main() return values and exit()

    What exactly is the advantage of using:
    int main()
    over using:
    void main()
    And if returning a value is better, why? Also - if returning a value holds an advantage, how does it rank with stlib.h's exit(0)?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Read some of the topics on this page
    http://www.eskimo.com/~scs/C-faq/s11.html

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Well that asnwered my first question - thanks - but is there any difference between exit(0) and return 0?

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    You mean
    http://www.eskimo.com/~scs/C-faq/s11.html

    Better read the whole damn thing

  5. #5
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    There is one big difference between exit and return. Exit will cause the program to terminate even from within a function whereas return does not ( necessarily )...
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  2. Another weird error
    By rwmarsh in forum Game Programming
    Replies: 4
    Last Post: 09-24-2006, 10:00 PM
  3. Why only 32x32? (OpenGL) [Please help]
    By Queatrix in forum Game Programming
    Replies: 2
    Last Post: 01-23-2006, 02:39 PM
  4. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  5. problem with open gl engine.
    By gell10 in forum Game Programming
    Replies: 1
    Last Post: 08-21-2003, 04:10 AM