#include <stdio.h>
#include <string.h>
int main()
{
char buf1[]="hello";
char buf2[]="world";
char buf[20];
int buf1_len = strlen(buf1);
int buf2_len = strlen(buf2);
memcpy(buf,buf1,buf1_len);//从存储区buf2复制n个字节到存储区buf
printf("buf = %c",buf);
return 0;
}
运行结果:
buf = helloworld