int makeList(List_t* list)
{
list = malloc(sizeof(List_t));
if(!list){
return list_makeFail;
}else{
return list_success;
}
}
bool isEmpty(List* list)
{
return (list->head == NULL);
}
int main()
{
int ret;
List_t* testList;
ret = makeList(testList);
printf("make list is %d\n", ret);
ret = isEmpty(testList);
printf("list is empty : %s\n", ret ? "true":"false");
return 0;
}
测了一下是死在isEmpty()
另外试了一下:
List_t testList = malloc(sizeof(List_t));
isEmpty(testList);
这样是没问题的,我是哪边的观念有错误吗?
平台是centos7,用的是C