Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: net.lang.c Subject: Re: Questions about C on a Prime (primix) Message-ID: <2023@brl-smoke.ARPA> Date: Sun, 23-Mar-86 18:38:56 EST Article-I.D.: brl-smok.2023 Posted: Sun Mar 23 18:38:56 1986 Date-Received: Tue, 25-Mar-86 05:22:50 EST References: <988@plus5.UUCP> <325@hadron.UUCP> Reply-To: gwyn@brl.ARPA Organization: Ballistic Research Lab (BRL) Lines: 23 In article <325@hadron.UUCP> jsdy@hadron.UUCP (Joseph S. D. Yao) writes: >In article <988@plus5.UUCP> hokey@plus5.UUCP (Hokey) writes: >>I was told that their C port keeps the 8th bit *on* for all ascii characters. >>This seems kind of strange. Near as I can tell, this means the following >>code fragment won't work: >> strcpy(dst, src) >> char *dst; >> char *src; { >> while(*dst++ = *src++) ; >> return;} >I've never really liked this kind of code: it always seemed to me >to be assuming something that, someday, on some weird machine, would >fail. Surprise! >My rule is to always use an explicit reference to a defined constant: > while ((*dst+= = *src++) != NUL); >This way, if my character set changes, I worry about this less. By >the way, will your P**** machine take a constant like > #define NUL '\0' >and turn it into an eighth-high character? No, the NUL terminator (both in practice and as you #define it) will be a 0-valued byte. The original code, although ugly, is correct.