void mystrncpy(char *op, const char *ip, const int ncharmax) { int n = 0; while ((*ip != '\0') && (n++ < ncharmax)) *op++ = *ip++; } (Walks off mumbling about being bitten by corrupted strings TOO often...) Um. Those terminating nulls are important (this came up quite recently, thanks to a jihad to eliminate all non-counted string copies.) How about: void mystrncpy(char *op, const char *ip, const int ncharmax) { char c; int n = 0; do { *op = *ip++; if (++n >= ncharmax) *op = '\0'; } while (*op++ != '\0'); } I wonder at what point one should just do: faster_strncopy (op, ip, max) { memcpy(op, ip, max); *(op+max-1) = '\0'; } On short strings, the missing test instructions oughta just about balance out any extra bytes that you copy. On longer strings, you save more test instructions, AND you might get highly optimized behavior out of memcpy (word moves on machines with large words, unrolled loops, all sorts of nasty stuff.) BillW