Sujet : Re: Two questions on arrays with size defined by variables
De : jameskuyper (at) *nospam* alumni.caltech.edu (James Kuyper)
Groupes : comp.lang.cDate : 10. Feb 2025, 05:03:52
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vobtr8$12bhh$1@dont-email.me>
References : 1 2 3 4 5 6 7
User-Agent : Mozilla Thunderbird
On 2/9/25 21:35, Janis Papanagnou wrote:
On 10.02.2025 01:38, Keith Thompson wrote:
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
...
int main (int argc, char * argv[])
{
...
return 0;
}
...
The "return 0;" is unnecessary but harmless in C99 and later.
>
That - returning a value when a function is declared to return
one - is actually a [maybe picky] coding-habit of mine. :-)
It's a reasonable habit to acquire. However, the interface for main()
was created back when there was no way to declare that a function didn't
return any value, and all functions by default returned "int" unless
explicitly declared otherwise. It made sense, therefore, for main() to
be declared as returning an int value that would be passed to the host
environment to indicate the exit status of the program.
Many programmers had no need to report an exit status, and therefore
didn't bother returning a value from main(). As a result, many
implementations failed to require it. Eventually the committee decided
to make a special case for main(), to accommodate those practices.