I can't seem to get my head around this, what is the basic difference between these two functions:
char *strncpy(char *str1, const char *str2, size_t count);
and
size_t strxfrm(char *str1, const char *str2, size_t count);
To me it seems they both copy count characters from str2 to str1. What I really want to know is, when should I use either of them?
The difference is in the return value:
The strcpy() and strncpy() functions return a pointer to the destination string.
Upon successful completion, strxfrm() shall return the length of the transformed string (not including the terminating null byte). If the value returned is n or more, the contents of the array pointed to by s1 are unspecified.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With