c - Isn't void in int main(void) redundant? -
this question has answer here:
- in c: func(void) vs. func() [duplicate] 2 answers
the c99 standard document have states that
6.7.5.3.14 identifier list declares identifiers of parameters of function. an empty list in function declarator part of definition of function specifies function has no parameters. empty list in function declarator not part of definition of function specifies no information number or types of parameters supplied.
what interpret sentence writing void
in function definition redundant. did correctly?
no, you're slightly wrong.
void
specifies there abosolutely no arguments passed.- empty parenthesis
()
indicates function can called any number of arguments, without generating warning.
note: remember, there no prototype defined or supplied implementation main()
.
maybe, c11
standard, chapter 5.1.2.2.1, describes better way,
the function called @ program startup named
main
. implementation declares no prototype function. shall defined return type ofint
, no parameters:int main(void) { /* ... */ }`
or 2 parameters (referred here
argc
,argv
, though names may used, local function in declared):int main(int argc, char *argv[]) { /* ... */ }
or equivalent;10) or in other implementation-defined manner.
Comments
Post a Comment