I am trying to make use of Array of nodes with dynamic memory allocation so that I can increase the number of nodes at runtime. However I seem to be getting an error which is unknown to me. I am probably using the array in wrong way, so please check and correct me. listNo used in the code is an integer variable.
Code:
Node* lists = (Node*) malloc(100 * sizeof(lists));
printf("\n Enter the number of lists:");
scanf("%d", &nbrOfLists);
if(nbrOfLists < 0)
return -1;
if(nbrOfLists>100)
lists = realloc(lists, 100 * sizeof(lists));
lists[listNo] = NULL; // getting error here incompatible types assigning Node from type 'void*'
lists[listNo]= insertValue(lists[listNo], val);
I mean each element in an array has first element of an individual linked list. The next element is another independent first node of another linked list.