Alan_T._Cote.OsbuSouth@Xerox.COM (04/12/88)
In article <6476@dhw68k.cts.com>, "David H. Wolfskill" <david@dhw68k.cts.COM> 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 ); }