c语言 memcpy 复制结构用法

Modified on: Mon, 18 Mar 2019 20:31:00 +0800 热度: 1,112 度

头文件 #include <string.h>

#include <stdio.h>
#include <string.h>
typedef struct{
    size_t x;
    size_t y;
}place;
int main()
{
    place a={1,2};
    place b;
    memcpy(&b,&a,sizeof(place));
    printf("(%zu,%zu)\n",b.x,b.y);
}

输出:
(1,2)
Program ended with exit code: 0

添加新评论