Thread: int main (), main (), main (void), int main (void) HELP!!!

  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    11

    Angry int main (), main (), main (void), int main (void) HELP!!!

    whats the diff between int main (), main (), int main (void), and main (void) ???
    Children in the dark make accidents.

    Accidents in the dark make children.

  2. #2
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331

  3. #3
    Registered User
    Join Date
    May 2003
    Posts
    11
    i guess i should have checked this website first...

    thanks
    Children in the dark make accidents.

    Accidents in the dark make children.

  4. #4
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    This is what will happen to you if you use void main()--check out Salem's picture:

    http://cboard.cprogramming.com/showt...5&pagenumber=1

  5. #5
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    You should never use void main...if not because of salem's god-given right to injure you, then because it isnt even c++, have a read.

    http://www.research.att.com/~bs/bs_faq2.html#void-main

  6. #6
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    why do compilers accept it and why do professors and books teach it?
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  7. #7
    i want wookie cookies the Wookie's Avatar
    Join Date
    Oct 2002
    Posts
    455
    because it wasn't the standard then i guess.

  8. #8
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    Under regular function calling/returning in C and C++, if your don't ever want to return anything from a function, you define it's return type as void. For example, a function that takes no arguments, and returns nothing can be prototyped as:

    void foo(void);

    A common misconception is that the same logic can be applied to main(). Well, it can't, main() is special, you should always follow the standard and define the return type as int.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  2. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  3. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  4. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  5. Replies: 3
    Last Post: 05-13-2007, 08:55 AM