标签:main struct strlen des str div std memcpy mem
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[50]; int age; } zhangsan, wangsi; int main() { char name[20] = "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; }
标签:main struct strlen des str div std memcpy mem
原文地址:https://www.cnblogs.com/luckygxf/p/12273340.html