![How to write strcpy function in c language](https://img.php.cn/upload/article/000/000/020/5e41fc6b9580b763.jpg)
How to write strcpy function in C language
1. Build a basic C language program framework, pay attention to adding # includeHeader file
![1581382496911256.png How to write strcpy function in c language](https://img.php.cn/upload/image/536/264/692/1581382496911256.png)
2. Define two character arrays
![1581382502364886.png How to write strcpy function in c language](https://img.php.cn/upload/image/181/339/160/1581382502364886.png)
##3. strcpy function prototype :
char *strcpy(char *dest, const char *src);
Copy after login
strcpy copies the string starting from the src address and containing the '\0' terminator to the address space starting with dest. The return value type is char*. Here we do not accept the return value
![1581382516299679.png How to write strcpy function in c language](https://img.php.cn/upload/image/960/903/249/1581382516299679.png)
4. In this way, the test string is copied to the table array, and finally the string of the table array is printed out through puts
![1581382522974006.png How to write strcpy function in c language](https://img.php.cn/upload/image/569/812/985/1581382522974006.png)
5. Save and exit under Linux, compile through the gcc compiler,
Compilation instructions: gcc .c file name -o file name .out generated after compilation
For example: gcc strcpy.c -o strcpy.out
![1581382529765454.png How to write strcpy function in c language](https://img.php.cn/upload/image/107/613/831/1581382529765454.png)
3. Execute the compiled executable file
Instructions:. /strcpy.out
Press Enter to see the copied string output
![1581382535275494.png How to write strcpy function in c language](https://img.php.cn/upload/image/140/510/189/1581382535275494.png)
![1581382541406802.png How to write strcpy function in c language](https://img.php.cn/upload/image/877/827/608/1581382541406802.png)
Recommended learning:
c language video tutorial
The above is the detailed content of How to write strcpy function in c language. For more information, please follow other related articles on the PHP Chinese website!