If you need an array of linked lists, why use a pointer?
struct List{ adjListType list[10]; int size; };
Of course, you can also use a pointer, but then you need to show us how you allocate array memory using calloc ?
In accordance with the updated code in question. The following are the corrected errors ...
ListType newList(int numVerts){ ListType new = malloc(sizeof(struct List)); new->list = calloc(numVerts, sizeof(struct adjListType));
You may also need to return & new as a link, or you will create unnecessary copies ...
I will go to your code and update this answer if I find anything else. Meanwhile, it will be great if you tell us what mistake you get?
Also in your code shown, you set next and prev and current to NULL , but where you change these values ββ... otherwise you will continue to get NULL POINTER EXCEPTION
source share