title: How to print values of function pointer in C?
body: <p>I have a pointer to a function returning a const char pointer. My question is how to print the pointer and then also the object (the string itself) referenced by the pointer(s).</p>
  
  <p>Here is the code: </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  char const *func(void)
  {
      printf("Printed func string.\n");
      return "Pointed func string.\n";
  }
  
  int main(void) {
      char const *(*fp)(void) = func;
  
      /*print statements here*/
  
      return 0;
  }
  </code></pre>
  
  <p>I get either a <code>ISO C forbids conversion of function pointer to object pointer type</code> or some undefined behavior.</p>
  
  <p>EDIT:</p>
  
  <pre><code>int main(void) {
      char const *(*fp)(void) = func;
  
      unsigned char *p = (unsigned char *)&amp;fp;
      /*print statements here*/
      printf("The: %p\n",(char *) p);
  
  
      return 0;
  }
  </code></pre>
  
  <p>OUTPUT: <code>0x7fff36753500</code></p>
  
  <p>Is not correct.</p>