GIDNetwork > Things to Avoid in C/C++ -- void main(), Part 10
Register
« Reading a Single Character Naming Conventions »

Things to Avoid in C/C++ -- void main(), Part 10

by: WaltP - Oct 18, 2005

C/C++ programmers are sometimes allowed to do some things they really shouldn't. We are given functions that are supposed to be useful but aren't because of hidden faults, or taught ways to do things that are bad, wrong or not necessary. This post will discuss one of these.

void main()

main() is an integer function, and should be specified as such. Now I can get into long-winded explanation of why, but it's already been done, with examples.

I first turn your attention to an article by Steve Summit. He explains what could happen and why. How the improper form started and why it's been allowed to continue.

The second is by Alun Jones, with a real world example of an error.

Another good explanation is by Jack Klein.

So the bottom line is void main()

  1. is wrong according to the standards.

  2. is not guaranteed to work properly.

  3. may cause problems for the operating system.

Would you like to comment? This story has been viewed 51,145 times.
« Reading a Single Character Naming Conventions »

__top__

Copyright © GIDNetwork™ 2001 - 2014

Another website by J de Silva

Page generated in : 0.03482 sec.