int main(void)

This is a discussion on int main(void) within the C++ Programming forums, part of the General Programming Boards category; Im a pretty new C++ programmer, but i'm learning very quickly. Id like to know what: Code: int main(void) and ...

  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
    moi
    moi is offline
    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-01-2003, 11:26 PM

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