RE: A Question About C 10-17-2015, 02:16 PM
#7
(10-17-2015, 05:49 AM)0xDEAD10CC Wrote: This has nothing to do with return types so I have no idea what you're talking about. function() vs function(void) does make a difference though as the latter means that no arguments can be passed to it.He was actually asking two questions. The first question was asking about the difference between using "void" or nothing for the functions argument list. In my experience, I've never seen any code function written using a blank argument list that would have values being sent to it.
However, I did just read this over at stackoverflow: In C, in general, (void) means no arguments required in function call, while () means unspecified number of arguments.
I've always taken it for granted that they both, (void) and (), meant the same and have used either one when writing code.
Quote:Either way you should never omit the return type from any function, and you should never declare the main() function as returning void.I've never seen or written any function definition without including the return type. I'll use void when I'm not expecting the function to return anything.
As for using void as a return type for the main function, my compiler had never complained about the usage and I've never had a program crash when it exited. Perhaps using the int return type would be required for a windows program, but I've never had to use that for any of my DOS programs.
![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)