![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);
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!
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn