I have a pointer to a struct of type Map defined in an external header file:
typedef struct {
char *squares; //!< A pointer to a block of memory to hold the map.
int width; //!< The width of the map pointed to by squares.
int height; //!< The height of the map pointed to by squares.
} Map;
The pointer is initialised as follows:
struct Map *map_ptr;
map_ptr = create_map(*w_ptr, *h_ptr);
// create_map returns Map*, w_ptr and h_ptr are pointers to height and width fields for a map/maze.
How do I go about printing the values of width and height stored within the Map structure which is created in create_map? create_map is held in an external file and the only variable it passes back to main is the pointer to the map.
The following gives an error when compiling ("error: dereferencing pointer to incomplete type")
printf("Height = %d\n", map_ptr->height);
As far as I know, the pointer is valid as the code below prints a memory address:
printf("Pointer address for map = %p\n", map_ptr);