Re: Two questions on arrays with size defined by variables

Liste des GroupesRevenir à cl c 
Sujet : Re: Two questions on arrays with size defined by variables
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.c
Date : 10. Feb 2025, 07:57:06
Autres entêtes
Organisation : None to speak of
Message-ID : <878qqep9rx.fsf@nosuchdomain.example.com>
References : 1 2 3 4 5 6 7 8 9
User-Agent : Gnus/5.13 (Gnus v5.13)
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
On 10.02.2025 05:14, Andrey Tarasevich wrote:
On Sun 2/9/2025 6:35 PM, Janis Papanagnou wrote:
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. :-)
 
This is, of course, a purely stylistic matter. But still... `main` is
special.
>
I know.
>
And it kinda makes sense to acknowledge it special nature by
not doing explicit `return 0` from `main`. `main` looks cleaner without it.
>
Now I'm astonished by that comment (to say the least).
>
I'm regularly returning status and error information to the calling
instance to act upon it. And you're saying that I should not return
any value? Or only values that are different from 0? Or only 0 if I
also return other values? - Whatever; that sounds all wrong to me.
Or is 'return' deprecated or depreciated and we should now rewrite
our source code and replace every 'return' by 'exit()', or use now
only 'exit()' in the first place instead?
>
I don't think you will convince me to not return 0 only because in
the special case that there's nothing specified the current language
standards defines that per default it implicitly provides that value
for me.

Having a "return 0;" at the end of main() is neither obsolescent nor
deprecated.  It's still perfectly valid, with the expected semantics.

The only that changed in C99 is that reaching the closing "}" of
the main function does an implicit "return 0;".  This change was
borrowed from C++.

I do tend to dislike the change; it feels like an unnecessary special
case, and I used to advise people to add an explicit "return 0;"
anyway.  This was partly because C99 compilers were relatively rare,
and there were advantages to writing code that still worked with
C90-only compilers.

I usually omit the "return 0;", but I don't object to including it --
though I will occasionally mention in passing that it's "unnecessary
but harmless".  If nothing else, the history is interesting (at
least to me).

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */

Date Sujet#  Auteur
9 Feb 25 * Two questions on arrays with size defined by variables45Janis Papanagnou
9 Feb 25 `* Re: Two questions on arrays with size defined by variables44Andrey Tarasevich
9 Feb 25  +* Re: Two questions on arrays with size defined by variables41Janis Papanagnou
9 Feb 25  i+* Re: Two questions on arrays with size defined by variables10Keith Thompson
9 Feb 25  ii`* Re: Two questions on arrays with size defined by variables9Janis Papanagnou
10 Feb 25  ii `* Re: Two questions on arrays with size defined by variables8Keith Thompson
10 Feb 25  ii  `* Re: Two questions on arrays with size defined by variables7Janis Papanagnou
10 Feb 25  ii   +- Re: Two questions on arrays with size defined by variables1James Kuyper
10 Feb 25  ii   `* Re: Two questions on arrays with size defined by variables5Andrey Tarasevich
10 Feb 25  ii    `* Re: Two questions on arrays with size defined by variables4Janis Papanagnou
10 Feb 25  ii     `* Re: Two questions on arrays with size defined by variables3Keith Thompson
10 Feb 25  ii      `* Re: Two questions on arrays with size defined by variables2Janis Papanagnou
10 Feb 25  ii       `- Re: Two questions on arrays with size defined by variables1Keith Thompson
9 Feb 25  i+* Re: Two questions on arrays with size defined by variables6Michael S
9 Feb 25  ii`* Re: Two questions on arrays with size defined by variables5Janis Papanagnou
9 Feb 25  ii `* Re: Two questions on arrays with size defined by variables4Michael S
9 Feb 25  ii  +- Re: Two questions on arrays with size defined by variables1Janis Papanagnou
10 Feb 25  ii  `* Re: Two questions on arrays with size defined by variables2Keith Thompson
10 Feb 25  ii   `- Re: Two questions on arrays with size defined by variables1Janis Papanagnou
9 Feb 25  i+* Re: Two questions on arrays with size defined by variables20Waldek Hebisch
9 Feb 25  ii`* Re: Two questions on arrays with size defined by variables19Janis Papanagnou
9 Feb 25  ii +* Re: Two questions on arrays with size defined by variables13Andrey Tarasevich
9 Feb 25  ii i`* Re: Two questions on arrays with size defined by variables12Janis Papanagnou
9 Feb 25  ii i +* Re: Two questions on arrays with size defined by variables7Janis Papanagnou
9 Feb 25  ii i i`* Re: Two questions on arrays with size defined by variables6James Kuyper
10 Feb 25  ii i i +- Re: Two questions on arrays with size defined by variables1Waldek Hebisch
10 Feb 25  ii i i `* Re: Two questions on arrays with size defined by variables4Janis Papanagnou
10 Feb 25  ii i i  `* Re: Two questions on arrays with size defined by variables3David Brown
10 Feb 25  ii i i   `* Re: Two questions on arrays with size defined by variables2Janis Papanagnou
10 Feb 25  ii i i    `- Re: Two questions on arrays with size defined by variables1David Brown
9 Feb 25  ii i `* Re: Two questions on arrays with size defined by variables4Michael S
10 Feb 25  ii i  `* Re: Two questions on arrays with size defined by variables3Opus
10 Feb 25  ii i   `* Re: Two questions on arrays with size defined by variables2Michael S
10 Feb 25  ii i    `- Re: Two questions on arrays with size defined by variables1Opus
10 Feb 25  ii `* Re: Two questions on arrays with size defined by variables5Keith Thompson
10 Feb 25  ii  `* Re: Two questions on arrays with size defined by variables4Janis Papanagnou
10 Feb 25  ii   `* Re: Two questions on arrays with size defined by variables3Janis Papanagnou
10 Feb 25  ii    `* Re: Two questions on arrays with size defined by variables2Keith Thompson
10 Feb 25  ii     `- Re: Two questions on arrays with size defined by variables1Janis Papanagnou
9 Feb 25  i+* Re: Two questions on arrays with size defined by variables3Andrey Tarasevich
9 Feb 25  ii+- Re: Two questions on arrays with size defined by variables1Janis Papanagnou
9 Feb 25  ii`- Re: Two questions on arrays with size defined by variables1James Kuyper
9 Feb 25  i`- Re: Two questions on arrays with size defined by variables1James Kuyper
9 Feb 25  +- Re: Two questions on arrays with size defined by variables1James Kuyper
15 Feb17:19  `- Re: Two questions on arrays with size defined by variables1Tim Rentsch

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal