NOT Educating FORTRAN programmers to use C

Doug McDonald mcdonald at aries.scs.uiuc.edu
Wed Jan 24 02:15:33 AEST 1990


>> [...]
>>     src = str2;
>>     while (*src && remaining)  {
>>         *dst++ = *src++;
>>         remaining--;
>>     }
Assuming that it is known that remaining is less than the allocation
of either src or dst, then one could save the character at
(src + remaining), replace it with zero, copy until zero was hit,
and then fix up the marker byte. You provide the code and the
exact place to put the marker byte.

This takes only one loop with only one test.

Doug McDonald



More information about the Comp.lang.c mailing list