While reading the man page for strcpy
, I discovered the function stpcpy
also exists. However, the only difference I could notice in the man page is
The restrict
tells the compiler that s1
and s2
point to different arrays and that there is no overlap in the pointed-to arrays. In some cases this may allow the compiler to perform extra optimizations (i.e., it could possibly copy blocks of multiple characters without having to check for overlap).
Note also that the return value is different: stpcpy
returns a pointer to the \0
that was copied into the destination buffer while strcpy
returns a pointer to the beginning of the string (effectively it does a return s1;
).