title: Point void-pointer to char-pointer
body: <p>I have two pointers. A <code>char</code> pointer with the string "test", and a <code>void</code> pointer.
  I'm trying to have <code>pointer</code> point to the address of <code>string</code>.
  Here's my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(){
      void *pointer = NULL;
      char *string = "test";
      *(char*)pointer = &amp;string;
  
      printf("The string address: %p\n", string);
      printf("The string: %s\n", string);
      printf("The pointer address: %p\n", pointer);
      printf("The pointer points to: %p", *(char*)pointer);
  
      return 0;
  }
  </code></pre>
  
  <p>When I set <code>pointer</code> to be equal to the address of <code>string</code> on line 6 I get <code>makes integer from pointer without a cast</code>. How can I do this?<br><br></p>
  
  <p>Edit:
  I was printing the wrong addresses. I meant for the printf lines to look like this:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(){
      void *pointer = NULL;
      char *string = "test";
      pointer = &amp;string;
  
      printf("The string address: %p\n", &amp;string);
      printf("The string: %s\n", string);
      printf("The pointer address: %p\n", &amp;pointer);
      printf("The pointer points to: %p", pointer);
  
      return 0;
  }
  </code></pre>
  
  <p>It now properly prints out this:<br></p>
  
  <blockquote>
    <p>The string address: 0028FF18 <br>The string: test <br>The pointer address:
    0028FF1C <br>The pointer points to: 0028FF18</p>
  </blockquote>
  
  <p>So <code>string</code> and <code>pointer</code> are separate pointers and <code>pointer</code> points to <code>string</code>.</p>