原型:extern void *memcpy(void *dest, void *src, unsigned int count);
用法:#include <string.h>
功能:由src所指内存区域复制count个字节到dest所指内存区域。
说明:src和dest所指内存区域不能重叠,函数返回指向dest的指针。
举例:
// memcpy.c
#include <syslib.h>
#include <string.h>
main()
{
char *s="Golden Global View";
char d[20];
clrscr();
memcpy(d,s,strlen(s));
d[strlen(s)]=0;
printf("%s",d);
getchar();
return 0;
}C语言 memcpy 用法
最新推荐文章于 2025-09-26 23:20:14 发布
本文详细介绍了字符串操作函数memcpy的使用方法及注意事项。memcpy用于从源内存区域复制一定数量的字节到目标内存区域,但要求两个区域不能重叠。文中通过示例代码展示了如何正确使用此函数。
359

被折叠的 条评论
为什么被折叠?



