C language: Use pointers and function calls to compile the strcpy string copy Function
# Include <stdio. h> # include <assert. h>/* search for the function header file */char * my_strcpy (char * dest, const char * src)/* To pass parameters, and pass src to dest in sequence, pointer array, each address is */{char * ret = dest;/* The address received */assert (dest! = NULL); assert (src! = NULL);/* the pointer must be used to check whether the pointer is NULL by using the search function, avoid accidentally passing the empty address */while (* dest ++ = * src ++) {;} return ret;/* returns the ret as a string using char, the address */} int main () {char * p = "Hello world! "; Char arr [20];/* The reason for using the pointer p is that the array is equivalent to an address, and the completion of strcpy is equivalent to switching the addresses of the two */char * ret = my_strcpy (arr, p);/* give the p address to the array */printf ("% s", ret);/* print the string */return 0 ;}