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?
#include <stdio.h>
void * square (const void *num);
int main() {
float x, sq_int;
x = 6.543;
sq_int = square(&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);
}