title: Using malloc() and sizeof() to create a struct on the heap
body: <p>I'm trying to use malloc() and sizeof() to create a struct on the heap. Here is my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  struct Employee
  {
      char first[21];
      char last[21];
      char title[21];
      int salary;
  };
  
  
  struct Employee* createEmployee(char* first, char* last, char* title, int salary) // Creates a struct Employee object on the heap.
  {
      struct Employee* p = malloc(sizeof(struct Employee)); 
  
      if (p != NULL)
      {
          strcpy(p-&gt;first, first);
          strcpy(p-&gt;last, last);
          strcpy(p-&gt;title, title);
          p-&gt;salary, salary;
      }
      return p;
  
  }
  </code></pre>
  
  <p>No my compiler (Visual C++) tells me for the line <code>struct Employee* p = malloc(sizeof(struct Employee));</code> that the type "void *" can't be converted to the type "Employee *". I don't know what is wrong here. Seems as if struct Employee is a void but i don't understand why...</p>