title: Invalid conversion 'void*' to 'struct*'
body: <p>I'm beginner in C. I'm trying to practice with solving some problems. And I'm getting this error when I compile my code. </p>
  
  <blockquote>
    <p>[Error] invalid conversion from 'void*' to 'triangle*' [-fpermissive]</p>
  </blockquote>
  
  <p>The code and purpose is explained below.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;math.h&gt;
  
  struct triangle
  {
      int a;
      int b;
      int c;
  };
  
  typedef struct triangle triangle;
  
  //sort_by_area() function is here
  int main()
  {
      int n;
      scanf("%d", &amp;n);
      triangle *tr = malloc(n * sizeof(triangle));
      for (int i = 0; i &lt; n; i++) {
          scanf("%d%d%d", &amp;tr[i].a, &amp;tr[i].b, &amp;tr[i].c);
      }
      sort_by_area(tr, n);
      for (int i = 0; i &lt; n; i++) {
          printf("%d %d %d\n", tr[i].a, tr[i].b, tr[i].c);
      }
      return 0;
  }
  </code></pre>
  
  <p>As you can see I have structure and I tried to allocate memory for it with the quantity of input. And try to use it for <code>sort_by_area</code> function. But the problem is <code>triangle *tr = malloc(n * sizeof(triangle));</code> line gives me the error mentioned above. </p>
  
  <p>Also this code is working for online compilers. I tried to run this code on <em>DEV C++</em> with default settings. I don't know about the versions and changing the versions of my compiler. I don't even know whether it is about the compiler version. But I am wondering why I'm getting this error. What is the logic behind.</p>