C library functions - strcpy ()
C standard library - <string.h>
description
C library functionschar * strcpy (char * dest, const char * src) copies the string pointed to by srcdest.
statement
Here is () statement strcpy function.
char *strcpy(char *dest, const char *src)
parameter
- dest - point to the destination array for storing copy content.
- src - the string to be copied.
return value
This function returns a pointer to the final destination string dest pointer.
Examples
The following example demonstrates the strcpy () function is used.
#include <stdio.h> #include <string.h> int main() { char src[40]; char dest[100]; memset(dest, '\0', sizeof(dest)); strcpy(src, "This is w3cschool.cc"); strcpy(dest, src); printf("最终的目标字符串: %s\n", dest); return(0); }
Let's compile and run the above program, which will result in the following:
最终的目标字符串: This is w3cschool.cc