c memcpy函数
void *memcpy(void *dest, void *src, unsigned n);string.h
返回值:dest*地址
功能:拷贝src n个字节到dest指向的内存
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define BUFFSIZE 1024
struct {
char name;
int age;
} zhangsan, wangsi;
int main() {
char name = "zhangsan";
memcpy(zhangsan.name, name, strlen(name) + 1);
zhangsan.age = 18;
memcpy(&wangsi, &zhangsan, sizeof(zhangsan));
printf("wangsi.name:%s, wangsi.age:%d\n", wangsi.name, wangsi.age);
return 0;
}
文档来源:51CTO技术博客https://blog.51cto.com/u_2498536/3304159
页:
[1]