Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utcs!mnetor!seismo!caip!clyde!cbatt!cbosgd!cbuxc!cbuxb!cbrma!aka From: aka@cbrma.UUCP Newsgroups: net.lang.c Subject: Re: Re: Precedent for use of = Message-ID: <4738@cbrma.UUCP> Date: Thu, 10-Jul-86 13:02:36 EDT Article-I.D.: cbrma.4738 Posted: Thu Jul 10 13:02:36 1986 Date-Received: Fri, 11-Jul-86 23:00:36 EDT References: <4824@sun.uucp> <499@cbmvax.cbmvax.cbm.UUCP> <6056@sri-spam.ARPA> Reply-To: aka@cbrma.UUCP (Andy Kashyap(Andy) x5299) Organization: AT&T-BL, RMAS, Columbus Lines: 41 In article <6056@sri-spam.ARPA> argv@sri-spam.UUCP (AAAARRRRGGGGv) writes: >In article <499@cbmvax.cbmvax.cbm.UUCP> daveh@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@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| +----------------------------------------------------------------------------+