On Thu, Mar 20, 2008 at 05:26:17PM +0100, Uwe Hermann wrote:
This doesn't put a terminating 0 on the string.
How about this? Untested, but should work.
char *strcpy(char *d, const char *s) {
- return strncpy(d, s, strlen(s));
- char *orig = d;
- while ((*(d++) = *(s++)));
- return orig;
}
I'd try to reuse strncpy() so that any optimizations need to be done in as few places as possible.
Save strlen() and just append the 0.
//Peter