【问题标题】:Memcpy within nested structures嵌套结构中的 Memcpy
【发布时间】:2014-02-15 07:38:46
【问题描述】:

我有两个嵌套结构。

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 呢?

【问题讨论】:

  • 你想要深拷贝还是浅拷贝?

标签: c structure memcpy


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-08
    • 1970-01-01
    • 2018-02-09
    • 1970-01-01
    相关资源
    最近更新 更多