Questions about C on a Prime (primix)

Joseph S. D. Yao jsdy at hadron.UUCP
Sat Mar 22 19:23:20 AEST 1986


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?

By the way, your indentation above seems to me a tad peculiar.
char *strcpy(dst, src)
  char *dst;
  register char *src;
{
	register char *d = dst;

	while ((*d++ = *src++) != NUL);
	return(dst);
}
-- 

	Joe Yao		hadron!jsdy at seismo.{CSS.GOV,ARPA,UUCP}



More information about the Comp.lang.c mailing list