strcpy
char * strcpy ( char * dest, const char * src ); | string.h |
cplusplus.com |
Copy string.
Copies the content pointed by src to dest stopping after the terminating
null-character is copied.
dest should have enough memory space allocated to contain src string.
Parameters.
Return Value.
dest is returned.
Portability.
Defined in ANSI-C.
Example.
/* strcpy example */ #include <stdio.h> #include <string.h> main () { char str1[]="Sample string"; char str2[40]; char str3[40]; strcpy (str2,str1); strcpy (str3,"copy successful"); printf ("str1: %s\nstr2: %s\nstr3: %s\n",str1,str2,str3); return 0; }Output:
See also.
strcat,
strncat,
strncpy,
memcpy