如何将两个单独的结构传递给接受单个指针的函数?

Dro*_*per 1 c struct pointers

我有一个只有一个(void*)数据传输指针的函数.但我需要使用该指针同时传输两个不同的结构(struct Astruct B)(void*).是否可以通过此指针存储一个接一个结构,然后使用结构大小和偏移量访问数据?

Gov*_*mar 5

你可以这样做:

struct C 
{
    struct A myA;
    struct B myB;
};
Run Code Online (Sandbox Code Playgroud)

填充myAmyB变量C,然后将指针传递给struct C函数中的a.