question regarding to C
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
int main()
{
int n = 3;
double *tptr = malloc(n*sizeof(double));
if (tptr != NULL)
free(tptr);
return 0;
}
got such error:
error C2440: 'initializing' : cannot convert from 'void *' to 'double *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
what's wrong with it? Thanks
#include <stdlib.h>
#include <stddef.h>
int main()
{
int n = 3;
double *tptr = malloc(n*sizeof(double));
if (tptr != NULL)
free(tptr);
return 0;
}
got such error:
error C2440: 'initializing' : cannot convert from 'void *' to 'double *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
what's wrong with it? Thanks