title: How to print member data from a struct using pointer to struct in C
body: <p>I have a pointer to a struct of type Map defined in an external header file:</p>
  
  <pre><code>typedef struct {
      char *squares; //!&lt; A pointer to a block of memory to hold the map.
      int   width;   //!&lt; The width of the map pointed to by squares.
      int   height;  //!&lt; The height of the map pointed to by squares.
  } Map;
  </code></pre>
  
  <p>The pointer is initialised as follows:</p>
  
  <pre><code>    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.
  </code></pre>
  
  <p>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.</p>
  
  <p>The following gives an error when compiling ("error: dereferencing pointer to incomplete type")</p>
  
  <pre><code>printf("Height = %d\n", map_ptr-&gt;height);
  </code></pre>
  
  <p>As far as I know, the pointer is valid as the code below prints a memory address:</p>
  
  <pre><code>printf("Pointer address for map = %p\n", map_ptr);
  </code></pre>