Hi,
What's wrong with using the following (I got the idea from some of
Stevens' code)?
char *sstrcpy(char *dst, size_t n, const char *src) {
if (strlen(src) > (n - 1)) {
errno = ENOSPC;
return NULL;
}
strcpy(dst, src);
dst[n - 1] = '\0';
return dst;
}
(the first 's' stands for safe (I hope))
It's not MT safe, but other than that I can't see any problems.
Chris