c - 嵌套结构中的 Memcpy

标签 c structure memcpy

我有两个嵌套结构。

struct OS_CLASS {

  PAGE route_table[10];

}*sptr_vrf;

struct PAGE{
   int routes;
}


struct G-info{
   PAGE *displ_table;
} *global_info

我需要将 sptr_vrf->route_table[0] 复制到 global_info->displ_table。

如何使用 memcpy 来做到这一点?

最佳答案

memcpy(global_info->displ_table, &sptr_vrf->route_table[0], sizeof(struct PAGE));

关于c - 嵌套结构中的 Memcpy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21794789/

相关文章:

C内联汇编内存拷贝

64-bit - memcpy() 性能 - Ubuntu x86_64

无法理解这段C代码片段

c - C 故障中的二维动态数组

比较高值和低值以调用函数

inheritance - golang 关注点分离与可用性

c - C中的结构和函数中的结构

opengl-es - glMapBuffer 在 OpenGL-ES 2.0 中未声明

c - 使用右指针类型,不想用 void * 进行转换

c - socket() 返回 -1 但 errno 0