title: How to cast a void pointers to float to be used in a function in C?
body: <p>I changed a code so that it could accept floats in a void pointer cast and use it in a function but while it was working with ints before making adjustment to it made the "incompatible types when assigning to type 'float' from type 'void *'" after I changed it to floats, could some one help where am I making a mistake?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  void * square (const void *num);
  
  int main() {
    float x, sq_int;
    x = 6.543;
    sq_int = square(&amp;x);
    printf("%f squared is %f\n", x, sq_int);
    return 0;
  }
  
  void* square (const void *num) {
    static float result;
    result = (*(float *)num) * (*(float *)num);
    return(result);
  } 
  </code></pre>