Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site hou3c.UUCP Path: utzoo!linus!security!genrad!grkermit!masscomp!clyde!burl!hou3c!ka From: ka@hou3c.UUCP (Kenneth Almquist) Newsgroups: net.lang.c Subject: Re: & operator Message-ID: <145@hou3c.UUCP> Date: Mon, 19-Dec-83 10:02:29 EST Article-I.D.: hou3c.145 Posted: Mon Dec 19 10:02:29 1983 Date-Received: Tue, 20-Dec-83 06:44:07 EST References: <481@sdcsla.UUCP> <1064@mit-eddie.UUCP> Organization: Bell Labs, Holmdel, NJ Lines: 23 From Steven M. Haflich: The variable `in' is indeed modified at the same time that the postfix ++ is evaluated, not after the entire statement. Consider: char *in = "123"; if (*in++ == *in++) ... ; /* ought never be true */ Although except for the `,' `&&' and `||' operators C explicitly does not specify order of evaluation within expressions (and therefore expressions which use multiple `++' and `--' operators on the same variable are usually crocky) I see no reason why the above conditional could not be used to check whether the first two characters of a string (known to be at least length two) are the same. Although there may be some support for this view in the C manual, this is not the interpretation of the people in Murrey Hill. Be warned that C compilers may not always perform the increment immediately after fetching the value of the variable. Thus the above statement could be compiled as temp = in; /* save value of "in" before incrementing it */ in += 2; /* perform both post-increments with one addition */ if (*temp = *temp) ... ; Kenneth Almquist