C语言--strcpy()函数
strcpy,即string copy(字符串复制)的缩写。 strcpy是一种C语言的标准库函数,strcpy把含有 ' '\0'结束符的字符串复制到另一个地址空间,返回值的类型为char*。 C语言 strcpy() 函数用于对字符串进行复制(拷贝)。 头文件:string.h 语法/原型: char* strcpy(char* strDestination, const char* strSource); 参数说明: strDestination:目的字符串。 strSource:源字符串。 strcpy() 会把 strSource 指向的字符串复制到 strDestination。 必须保证 strDestination 足够大,能够容纳下 strSource,否则会导致溢出错误。 返回值:目的字符串,也即 strDestination。 【实例】使用C语言 strcpy() 函数将字符串 src 复制到 dest。 #include <stdio.h> #include <string.h> int main(){ char dest[10] = { 0 }; char src[10] = { "liangchen" }; strcpy(dest, src); puts(dest); return 0; }//输出:liangchen 来源: https:/