Try to compile you code with a serious ANSI C compiler, from C89 to C11, and you will get the same error:
Test.c(9): error #2168: Operands of '=' have incompatible types 'double *' and 'int *'.
Test.c(11): error #2168: Operands of '=' have incompatible types 'double *' and 'char *'.
Test.c(13): error #2168: Operands of '=' have incompatible types 'double *' and 'float *'.
I suppose that the online compiler is somewhat trimmed to accept any code also pre-ansi.
C is still a weak typed language, but such errors are not accepted by actual standard level.
C++ is more strong typed language (it needs it to work), so even the online compielr gives you the error.
The need of a universal pointer, void *
, is absolutely required to act as a general pointer to be interchanged.
solved Purpose of void*