brix99luftballons said:
>
>
> Richard Heathfield ha scritto:
<snip>
>> If argc is 0, the behaviour is undefined. If it is >= 1, argv[0] must
>> represent the program name in some way, but need not be a string
>> representing the invocation name for the program. It could even be a
>> pid!
>>
> argc must be 1 (the program name ia always passed as argument), by
> standard.
Wrong.
> But, yes, it is best to check it...
Right, so let's do that. See 2.1.2.2 of C89 or 5.1.2.2.1 of C99:
* The value of argc shall be nonnegative.
* argv[argc] shall be a null pointer.
* If the value of argc is greater than zero, the array members
argv[0] through argv[argc-1] inclusive shall contain pointers to
strings, which are given implementation-defined values by the host
environment prior to program startup. The intent is to supply to the
program information determined prior to program startup from elsewhere
in the hosted environment. [...]
It is clear from the above that argc may be 0.
>>> return(-1);
>>>
>>
>> This has no ****table meaning (and the parentheses are redundantly
>> superfluous).
>>
> I'm not agree, it' more readable.
Please explain why parentheses make the return code more readable. Does
this apply to every expression, or just to the expression that
(optionally) follows a return statement? If so, why is return special?
>>> fd=fopen(argv[1], "rb");
>>> ...
>>> return(0);
>>>
>>
>> Again, the parentheses are superfluously redundant.
>>
> Question of style: for me it is better to place parentesis around the
> returned value.
> What about an horrible return like this one ????
> return a*32 / b + c - d * e / oh_my_good ;
What makes you think that adding parentheses helps? If the reader can't
comprehend a*32 / b + c - d * e / oh_my_good, why are they more likely to
comprehend (a*32 / b + c - d * e / oh_my_good)?
<snip>
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www.
+rjh@[EMAIL PROTECTED]
users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999


|