Thread: int main(void)

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    72

    int main(void)

    Im a pretty new C++ programmer, but i'm learning very quickly. Id like to know what:

    Code:
    int main(void)
    and how it is different from
    Code:
    main()
    what does it do that main() cant do.

  2. #2
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    int main(void)
    This declares that main returns an integer. main() should always return an integer.
    This is optional, it'd be the same if you left it out... included for clarity

    As for just plain main(), it looks like a syntax error to me. No return type.

  3. #3
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946
    Originally posted by Eibro
    int main(void)
    This declares that main returns an integer. main() should always return an integer.
    This is optional, it'd be the same if you left it out... included for clarity

    As for just plain main(), it looks like a syntax error to me. No return type.
    in c, main () is the same as int main (), because a function with no return type is implicitly assumed to return int
    hello, internet!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. can some one please tell me the cause of the error ?
    By broli86 in forum C Programming
    Replies: 8
    Last Post: 06-26-2008, 08:36 PM
  2. Moving Average Question
    By GCNDoug in forum C Programming
    Replies: 4
    Last Post: 04-23-2007, 11:05 PM
  3. getting a headache
    By sreetvert83 in forum C++ Programming
    Replies: 41
    Last Post: 09-30-2005, 05:20 AM
  4. Half-life SDK, where are the constants?
    By bennyandthejets in forum Game Programming
    Replies: 29
    Last Post: 08-25-2003, 11:58 AM
  5. Quack! It doesn't work! >.<
    By *Michelle* in forum C++ Programming
    Replies: 8
    Last Post: 03-02-2003, 12:26 AM