c - What's the difference between strcpy and stpcpy? -


while reading man page strcpy, discovered function stpcpy exists. however, difference notice in man page is:

char * stpcpy(char *s1, const char *s2);  char * strcpy(char *restrict s1, const char *restrict s2); 

so, restrict means here?

the restrict tells compiler s1 , s2 point different arrays , there no overlap in pointed-to arrays. in cases may allow compiler perform optimizations (i.e., possibly copy blocks of multiple characters without having check overlap).

note return value different: stpcpy returns pointer \0 copied destination buffer while strcpy returns pointer beginning of string (effectively return s1;).


Comments