c语言复制字符串的函数

c语言复制字符串的函数


2024年2月7日发(作者:)

c语言复制字符串的函数

C语言 strcpy() 函数用于对字符串进行复制(拷贝)。

头文件:string.h

语法/原型:

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] = { "" };

strcpy(dest, src);

puts(dest);

return 0;

}

运行结果:


发布者:admin,转转请注明出处:http://www.yc00.com/news/1707279121a1487910.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信