Programming Reference/Librarys
Question & Answer
Q&A is closed
strcpy copy a c string pointed by str2 into the array pointed by str1 including the terminating null character.
/* * strcpy c example code * http://code-reference.com/c/string.h/strcpy */ #include <stdio.h> /* including standard library */ #include <string.h> int main( void ) { char string[] = "copy me"; /* the size of the array is calculated automatically */ char string2[20]; if( strcpy(string2, string) != 0 ) printf( "copy success: %s\n", string2 ); else printf( "copy failure\n" ); return 0; }
user@host:~$ ./strcpy copy success: copy me