【发布时间】:2021-08-19 21:05:22
【问题描述】:
我是第一次提出问题,我会尽量简洁,我正在尝试为列表中的列表分配空间,然后访问其成员( int begin int end )。
typedef struct patient{
int id_patient;
int id_medic;
char name[15];
float presale;
struct seq *sequence;
}patient;
typedef struct seq{
int begin;
int end;
struct seq *next;
}seq;
struct patient* patient_list;
patient_list = malloc(sizeof(patient));
但是我无法访问内部列表中的数据
patient_list->sequence->begin = 10
printf("%d",patient_list->sequence->begin)
代码以0xC0000005退出,这应该是由于如何访问非法内存区域。
为什么会发生这种情况?我只写了感兴趣的代码,因为上面的列表有效。
【问题讨论】:
标签: c memory allocation