This shows you the differences between two versions of the page.
c:string.h:strcpy [2014/04/05 05:01] 188.113.222.212 |
c:string.h:strcpy [2024/02/16 01:06] (current) |
||
---|---|---|---|
Line 3: | Line 3: | ||
<code c> | <code c> | ||
#include <string.h> | #include <string.h> | ||
- | //#include <windows.h> /* uncomment this for Windows */ | + | char *strcpy(char *str1, const char *str2); |
- | + | ||
- | char *strcpy(char *str1, const char *str2); | + | |
</code> | </code> | ||
Line 19: | Line 17: | ||
*/ | */ | ||
#include <stdio.h> /* including standard library */ | #include <stdio.h> /* including standard library */ | ||
- | //#include <windows.h> /* uncomment this for Windows */ | ||
- | |||
#include <string.h> | #include <string.h> | ||
- | int main( void ) { | + | int main( void ) |
- | + | { | |
- | char string[] = "copy me"; /* the size of the array is calculated automatically */ | + | char string[] = "copy me"; /* the size of the array is calculated automatically */ |
- | char string2[20]; | + | char string2[20]; |
- | + | ||
- | + | ||
- | if( strcpy(string2, string) != 0 ) | + | |
- | printf( "copy success: %s\n", string2 ); | + | |
- | else | + | |
- | printf( "copy failure\n" ); | + | |
- | return 0; | + | if( strcpy(string2, string) != 0 ) |
+ | printf( "copy success: %s\n", string2 ); | ||
+ | else | ||
+ | printf( "copy failure\n" ); | ||
+ | return 0; | ||
} | } | ||
</code> | </code> |