Questions about C on a Prime (primix)
Doug Gwyn
gwyn at brl-smoke.ARPA
Mon Mar 24 09:38:56 AEST 1986
In article <325 at hadron.UUCP> jsdy at hadron.UUCP (Joseph S. D. Yao) writes:
>In article <988 at plus5.UUCP> hokey at 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.
More information about the Comp.lang.c
mailing list