on-internet
← Community

What is the best alternative to strncpy()?

Stack Overflow ·

The function strncpy() doesn't always null terminate so I want to know what is the best alternative that always null terminates? I want a function that if: strlen(src) >= n /*n is the number of characters to be copied from source*/ there's no need to add further code like this: buf[sizeof(buf)-1] = 0;

Comments

Sign in or sign up to comment and upvote.

No comments yet.