I've got a linked list and I'm trying to make a temporary array to help me address each node while I build the rest of the structure, then I intend to free the array but it seems I can't store the address of the struct into a pointer array.
Here's a boiled down version of where I'm having problems:
vertex *vertexIndex = NULL;
vertex *vertexHead = NULL;
vertexHead = malloc(sizeof(vertex));
vertexHead->vertexNum = 5;
vertexIndex = malloc(sizeof(vertex*));
vertexIndex[0] = vertexHead; //<<<<<<<<<<< Error on this line
printf("%u\n", (vertexHead[0])->vertexNum);
main.c:72:19: error: incompatible types when assigning to type ‘vertex’ from type ‘struct vertex *’
Any help would be greatly appreciated.
EDIT
Here are the structs
struct edgeStruct {
unsigned int edgeTo;
struct edgeStruct *nextEdge;
};
typedef struct edgeStruct edge;
struct vertexStruct {
unsigned int vertexNum;
edge *edgeHead;
struct vertexStruct *nextVertex;
};
typedef struct vertexStruct vertex;
sizeof(vertex*)? Although you seem to be populate an array by generating a pointer? I'm trying to understand what you are trying to do, unsuccessfully?!