C语言strcpy()函数

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

使用示例

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

#include <stdio.h>  
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);
}

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

Value of second string is: xuhuhu.com

上一篇: C语言strlen()函数 下一篇: C语言strcat()函数