C语言教程:字符串strcpy()函数

strcpy(destination,source)函数将源字符串(source)复制到目的(destination)字符串中。

使用示例

创建一个源文件:string_strcpy.c,其代码如下所示 -

#include   
void main()
{
    char ch[20] = { 'y', 'i', 'i', 'b', 'a', 'i', '.', 'c', 'o', 'm', '\0' };
    char ch2[20];
    strcpy(ch2, ch);
    printf("Value of second string is: %s \n", ch2);
}

C

执行上面示例代码,得到以下结果 -

Value of second string is: yiibai.com