Precedent for use of =
aka at cbrma.UUCP
aka at cbrma.UUCP
Fri Jul 11 03:02:36 AEST 1986
In article <6056 at sri-spam.ARPA> argv at sri-spam.UUCP (AAAARRRRGGGGv) writes:
>In article <499 at cbmvax.cbmvax.cbm.UUCP> daveh at cbmvax.cbm.UUCP (Dave Haynie) writes:
>>> if (i = 0) {
>>> /* do something */
>>> }
>>> else {
>>> /* do something else */
>>> }
>>>
>>> is legal C and usually /* does something else */ than you expected :-)
>>
>>As long as you're writing in C, and you REALLY know the language, the above
>>construct would be ridiculous.
>
>I disagree and I believe you do, too. If you really look for this
>construct, it is quite common in C, altho good programmers comment
>that they know what they're doing here... for example, my favorite:
>
>main(argc, argv)
>char **argv;
>{
> char *prog_name, *rindex();
>
> if (prog_name = rindex(*argv, '/')) /* find last '/' in argv[0] */
> prog_name++; /* set prog_name to string following last '/' */
> else prog_name = *argv; /* program was exec-ed from same dir or in PATH */
> /* etc... */
>}
>
>dan (argv at sri-spam.arpa)
Look again, Dan, at the original posting.
The 'true' branch of the 'if' statement is *NEVER* executed.
--
+----------------------------------------------------------------------------+
| | Andy Kashyap |
| | AT&T Bell Labs |
| | Columbus OH |
| Say Goodnight Gracey...Gracey?...Gracey?!!...HEY!!! | ..!cbosgd!cbrma!aka|
+----------------------------------------------------------------------------+
More information about the Comp.lang.c
mailing list