c - How do I declare a pointer to a struct within a struct? -
instead of being int, prev pointer vertex. however, can't declare prev vertexpointer because typedef vertexpointer comes afterwards. how should declare prev? #include <stdio.h> #include <stdlib.h> #include <time.h> //function generates random float in [0,1] float rand_float(); //all info vertex typedef struct{ int key; int prev; float loc[4]; } vertex; //using pointer typedef vertex *vertexpointer; you try this typedef struct vertex{ int key; struct vertex *prev; float loc[4]; } vertex;