迷茫2017-04-17 14:53:35
Pointers must be initialized before use
int main() {
ArrayListPtr list;
Init(list);
/*
//两种改法
ArrayList list;
Init(&list) // 以下的操作都不是指针,访问成员要改为`.`
//或者
ArrayListPtr list = (ArrayListPtr)malloc(sizeof(ArrayList));
Init(list);
*/
printf("length: %d\n", list->length);
printf("size: %d\n", list->size);
return 0;
}
怪我咯2017-04-17 14:53:35
The first list is a dirty pointer, does not assign nullptr, and does not point to any legal memory;
The second list is a legal ArrayList address;