Table of contents
Use strcpy in the library function
Use strcpy in the library function
When using the strcpy function, remember to quote the header file #include <string.h>. strcpy is to copy the content of arr2 to arr1
Make a copy function yourself
We create a My_strcpy function by ourselves, which changes the address of the content in the array through pointers
optimize code
Optimization 1.0
Simplifies the steps in the sub-function to make the code look more concise
Optimization 2.0
This solves a small problem in 1.0, that is, when arr2 is a null pointer, the code cannot run. Here we use an assert function to deal with it. Remember to reference the header file here #include <assert.h>
Here, if we want to be an excellent programmer, we must simplify the code as much as possible with a good code style.