The strcpy() function is used in C language to copy one string to another string. Its usage is as follows: declare two string variables, one to store the target string and the other to store the source string. Initialize source string. Call the strcpy() function to copy the source string to the destination string.
Usage of strcpy function in C language
The strcpy() function is used in C language to convert a Copy a string into another string. The syntax is as follows:
<code class="c">char *strcpy(char *dest, const char *src);</code>
Among them:
How to use strcpy() function?
Sample code:
<code class="c">#include <stdio.h> #include <string.h> int main() { char dest[20]; char src[] = "Hello World!"; strcpy(dest, src); printf("%s\n", dest); return 0; }</code>
Key points:
The above is the detailed content of How to use strcpy in c language. For more information, please follow other related articles on the PHP Chinese website!