我需要读取保存在具有旧结构的目录中的文件(下面发布的第一个)并将它们转换为新结构(第二个)。
struct char_file_u
{
int iClass;
struct char_skill_data skills[MAX_SKILLS];
}
struct char_fileNew_u
{
int iClass;
struct char_skill_data skills[MAX_SKILLS_NEW];
char name[20];
char authcode[7];
}
最佳答案
您可以开发一个新函数,该函数必须采用 struct char_file_u 并在 struct char_fileNew_u 中添加字段。
唯一棘手的一点是,您必须小心 MAX_SKILLS 和 MAX_SKILLS_NEW 的值,它们可能不同。
关于c - 如何使新结构与旧结构兼容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56356845/