strcpy,即string copy(字符串复制)的缩写,是一种C语言的标准库函数。
strcpy函数的作用:对字符串进行复制(拷贝),把含有“\0”结束符的字符串复制到另一个地址空间,返回值的类型为“char*”。
在C语言函数中:
头文件:#include 和 #include
原型声明:char* strcpy(char* strDestination, const char* strSource);参数说明:
strDestination:目的字符串。
strSource:源字符串。
strcpy() 会把 strSource 指向的字符串复制到 strDestination。
必须保证 strDestination 足够大,能够容纳下 strSource,否则会导致溢出错误。
返回值:目的字符串,也即 strDestination。
示例:使用C语言 strcpy() 函数将字符串 src 复制到 dest。#include
#include
int main(){
char dest[50] = { 0 };
char src[50] = { "http://c.html.cn" };
strcpy(dest, src);
puts(dest);
return 0;
}
运行结果:http://c.html.cn
更多web开发知识,请查阅 HTML中文网 !!
77334209