title: Passing a pointer to a struct as a function argument
body: <p>I'm trying to pass a pointer to a struct over to a separate function. But when I go to compile, I get <code>warning: passing argument 1 of 'build_network_state' from incompatible pointer type</code></p>
  
  <p>This is in a helper function the compiles into my program:</p>
  
  <pre><code>typedef struct router {
      int num;
      char label[64];
      Topology *topology;
  } Router;
  </code></pre>
  
  <p>This is from the .c file:</p>
  
  <pre><code>void build_network_state(Router *ptr) {
  
      fprintf(stdout, "Hello from router %s\n", ptr-&gt;label);
  }
  
  int main(int argc, char *argv[]) {
  
      Router* this_router = malloc(sizeof(Router));
  
      ...
  
      fprintf(stdout, "test: %s\n", this_router-&gt;label); // output looks fine if I comment the next line
      build_network_state(&amp;this_router);
  }
  </code></pre>