Loading...
Select Version
&pagelevel(4)&pagelevel
Definition | #include <string.h> char *strcpy(char *s1, const char *s2);
|
Return val. | Pointer to the result string s1. |
Notes | Strings terminated with the null byte (\0) are expected as arguments.
The behavior is undefined if memory areas overlap. |
Example | The following program outputs the contents of s1 and s2, then calls #include <stdio.h>
#include <string.h>
int main(void)
{
char s1[] = "Anne is pretty !";
char s2[] = "Mary too !";
printf("Contents s1: %s\nContents s2: %s\n", s1, s2);
strcpy(s1, s2); /* copy s2 to s1 */
printf("After strcpy:\nContents s1: %s\nContents s2: %s\n", s1, s2);
return 0;
}
|
See also | strncpy |