On Mon, Jan 26, 2009 at 12:08 PM, Sumantra Dutta Roy <[email protected]> wrote: > > Amit, you should get a warning, not an error.
More precisely, by design (or may be it is in the posix standard), all programs (not necessarily C) have to return a value indicating whether the program ran successfully or not (to the shell?). This is exactly why things like $ make && ./a.out (please note that $ make ; ./a.out is different) work in Linux (and probably not on WinBlows). This is why main() __must__ (good practice) return an integer where a zero indicates successful execution and non-zero (positive or negative) as error. You can see what your program returns immediately after execution as follows $ ./a.out $ echo $? If you do not use int (in your case void), the compiler would force it to be an integer and probably force a zero return value (which is bad practice). And as Dr. Roy said, it should be a warning not an error (which is normally only displayed when you use -Wall flag with gcc). Sharad --~--~---------~--~----~------------~-------~--~----~ l...@iitd mailing list -- group http://groups.google.com/group/iitdlug -~----------~----~----~----~------~----~------~--~---
