C examples for string.h:strcpy
function
<cstring> <string.h>
Copies the C string from source into the destination, including the terminating null character.
char * strcpy ( char * destination, const char * source );
Parameter | Description |
---|---|
destination | Pointer to the destination array. |
source | C string to be copied. |
destination is returned.
#include <stdio.h> #include <string.h> int main ()/*from w ww .j ava2 s .c o m*/ { 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; }