title: Conversion from double to pointer
body: <p>I'm quite newbie in C and now I'm trying to implement basic generic linked list with 3 elements, each element will contain a different datatype value — <code>int</code>, <code>char</code> and <code>double</code>.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  struct node
  {
      void* data;
      struct node* next;
  };
  
  struct node* BuildOneTwoThree()
  {
      struct node* head   = NULL;
      struct node* second = NULL;
      struct node* third  = NULL;
  
      head    = (struct node*)malloc(sizeof(struct node));
      second  = (struct node*)malloc(sizeof(struct node));
      third   = (struct node*)malloc(sizeof(struct node));
  
      head-&gt;data = (int*)malloc(sizeof(int));
      (int*)(head-&gt;data) = 2;
      head-&gt;next = second;
  
      second-&gt;data = (char*)malloc(sizeof(char));
      (char*)second-&gt;data = 'b';
      second-&gt;next = third;
  
      third-&gt;data = (double*)malloc(sizeof(double));
      (double*)third-&gt;data = 5.6;
      third-&gt;next = NULL;
  
      return head;
  }
  
  int main(void)
  {
      struct node* lst = BuildOneTwoThree();
  
      printf("%d\n", lst-&gt;data);
      printf("%c\n", lst-&gt;next-&gt;data);
      printf("%.2f\n", lst-&gt;next-&gt;next-&gt;data);
  
      return 0;
  }
  </code></pre>
  
  <p>I have no problem with the first two elements, but when I try to assign a value of type double to the third element I get an error: «<strong>can not convert from <code>double</code> to <code>double *</code></strong>».</p>
  
  <p>What is the reason for this error? Why don't I get the same error in case of <code>int</code> or <code>char</code>?
  And the most important question: how to fix this, how to assign a <code>double</code> value to the data field of the third element?</p>
  
  <p>The problem string is «<code>(double*)third-&gt;data = 5.6;</code>».</p>
  
  <p>Thanks.</p>