Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site rabbit.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!alice!rabbit!ark From: ark@rabbit.UUCP (Andrew Koenig) Newsgroups: net.lang.c Subject: neophyte's pointer question Message-ID: <2692@rabbit.UUCP> Date: Tue, 10-Apr-84 13:54:45 EST Article-I.D.: rabbit.2692 Posted: Tue Apr 10 13:54:45 1984 Date-Received: Wed, 11-Apr-84 07:02:36 EST Organization: AT&T Bell Laboratories, Murray Hill Lines: 24 If s is a character pointer then *s++ = (s & 0x7f); is definitely undefined, as the meaning of the "and" operator applied to a pointer is undefined (i. e. implementation dependent). Perhaps the question was intended this way: Is it OK to write: *s++ = (*s & 0x7f); The answer here is still no, because there is no guarantee as to whether s will be incremented before or after the right-hand-side is evaluated. If the author assumed that the right-hand-side would be evaluated first, the result desired would be to turn off all but the low-order seven bits of the character addressed by s and then increment s. This can be done as follows: *s++ &= 0x7f; Alternatively, one can write: *s = (*s & 0x7f); /* parens not really needed */ s++;