How about something like this:
snprintf (dest, 10, "%.*s", 10, src);
or maybe in this form:
Then again, I think that with such format even basic sprintf would be fine:Code:char *newstrncpy (char *d, const char *s, int maxLen) { snprintf (d, maxLen, "%.*s", maxLen, s); return (d); }
Code:char *newstrncpy (char *d, const char *s, int maxLen) { sprintf (d, "%.*s", maxLen, s); return (d); }