Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!nrl-cmf!cmcl2!brl-adm!adm!Alan_T._Cote.OsbuSouth@Xerox.COM From: Alan_T._Cote.OsbuSouth@Xerox.COM Newsgroups: comp.lang.c Subject: Re: info-c digest vol 1 number 26 Message-ID: <12922@brl-adm.ARPA> Date: 11 Apr 88 20:00:00 GMT Sender: news@brl-adm.ARPA Lines: 36 In article <6476@dhw68k.cts.com>, "David H. Wolfskill" writes, >terminating NUL, character by character. Then (assuming suitable >definitions of the variables in question), an algorithm to clear a given >string (str1) to a given value (other than NUL) could be coded: > > *str1 = ch; > for (c1 = str1; *++c1 != '\0'; *c1 = *(c1 -1)); > >or (remembering the characteristics of the implementation): > > *str1 = ch; > strcpy(str1+1, str1) (I hope I never have to maintain any of your code ;-) If you are assuming the implementation of strcpy() presented below, your code is likely to run for a very *long* time. Your terminating NUL is overwritten with ch before it is used to terminate the copy! char *strcpy(dst,src) char *dst, *src; { char *sv_dst; sv_dst = dst; while( *src != 0 ) *dst++ = *src++; return( sv_dst ); }