1
指針結構如果我有作爲分配內存內部結構
typedef struct _people {
char *name;
bool *exists;
struct _people **citizens;
} PEOPLE;
我怎麼去,這樣以人爲>公民[0]分配內存這樣的結構 - >名稱進行訪問?我試過
info->citizens = malloc(sizeof(PEOPLE *)*numbPeople);
然而,當我嘗試訪問信息 - > citizens->名字我得到了GDB的錯誤消息:
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000008