some people like void main()

This is a discussion on some people like void main() within the C++ Programming forums, part of the General Programming Boards category; I was at the local Dymocks bookstore the other day looking for my next C++ book when I came across ...

  1. #1
    Back after 2 years Panopticon's Avatar
    Join Date
    Dec 2002
    Posts
    262

    Smile some people like void main()

    I was at the local Dymocks bookstore the other day looking for my next C++ book when I came across a book by SAMS (i forgot the name) that teaches Visual C++. I had a quick flick through it and was amazed to see that all applicable examples had used void main() instead of int main(). I know ultimately its not a big deal in terms of functionality but Im trying to find out is there something I missed here? I mean, if the author is good enough to write a book that supposedly teaches C++ then you'd think he'd be familiar with standard C++ 'etiquette'.

    Or again I emphasize I may be missing something... (which i usually do)
    I AM WINNER!!!1!111oneoneomne

  2. #2
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078

    Re: some people like void main()

    Originally posted by Panopticon
    I was at the local Dymocks bookstore the other day looking for my next C++ book when I came across a book by SAMS (i forgot the name) that teaches Visual C++. I had a quick flick through it and was amazed to see that all applicable examples had used void main() instead of int main(). I know ultimately its not a big deal in terms of functionality but Im trying to find out is there something I missed here? I mean, if the author is good enough to write a book that supposedly teaches C++ then you'd think he'd be familiar with standard C++ 'etiquette'.

    Or again I emphasize I may be missing something... (which i usually do)
    It's not just etiquette, it's literally wrong. Does that mean that the whole book is bad? Not necissarily, but it just goes to show you that even though someone may write a book on a particular topic, it doesn't automatically make them an expert.

  3. #3
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    sometimes, not sure if it is the case with this book, but some books i have seen start with void main and then, later in the book, say this is wrong, and it should be int main.

  4. #4
    Back after 2 years Panopticon's Avatar
    Join Date
    Dec 2002
    Posts
    262
    Interesting... thanx for shedding light on the subject
    I AM WINNER!!!1!111oneoneomne

  5. #5
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146
    Panopticon, I'd suggest finding yourself a book that specifically states that it complies with the ISO draft standard.

    Oh, and in response to your title, some people like murder too, but that doesn't make it right
    FAQ

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

  6. #6
    Registered User
    Join Date
    Dec 2002
    Posts
    103

    What Stroustrup has to say :)

    Can I write "void main()"?

    The definition
    void main() { /* ... */ }

    is not and never has been C++, nor has it even been C. See the ISO C++ standard 3.6.1[2] or the ISO C standard 5.1.2.2.1. A conforming implementation accepts
    int main() { /* ... */ }

    and
    int main(int argc, char* argv[]) { /* ... */ }

    A conforming implementation may provide more versions of main(), but they must all have return type int. The int returned by main() is a way for a program to return a value to "the system" that invokes it. On systems that doesn't provide such a facility the return value is ignored, but that doesn't make "void main()" legal C++ or legal C. Even if your compiler accepts "void main()" avoid it, or risk being considered ignorant by C and C++ programmers.

    -----------------------
    Now we can bury this question
    -----------------------

  7. #7
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    We can bury it until it comes up again one or two weeks from now, at which time, someone will rexplain why it is bad, instead of linking to the hold discussion and being done with it.

  8. #8
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146
    Originally posted by SilentStrike
    We can bury it until it comes up again one or two weeks from now, at which time, someone will rexplain why it is bad, instead of linking to the hold discussion and being done with it.
    I just tell newbies not to argue about void main; otherwise, they will incur the wrath of other programmers on this board.

    And that's the umpteenth time I've seen that Stroustroup quote
    FAQ

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

  9. #9
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    with the standards quote...i don't think that panopticon needed to see that, he was just referring to the idea that an author of a c++ book would use something like void main(), and I believe polymorphic said it best with being an author of a book does not necessarily make that person an expert on the subject.

  10. #10
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    void main is already discussed too much. Search if you want to know more.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 03-05-2009, 09:25 AM
  2. can someone help me with these errors please code included
    By geekrockergal in forum C Programming
    Replies: 7
    Last Post: 02-10-2009, 01:20 PM
  3. Case Statement
    By danlee58 in forum C Programming
    Replies: 16
    Last Post: 11-23-2008, 07:46 PM
  4. Interpreter.c
    By moussa in forum C Programming
    Replies: 4
    Last Post: 05-28-2008, 05:59 PM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM

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