Possible Duplicate:
invalid conversion fromvoid*' tochar*' when using malloc?
I'm trying to allocate a matrix dinamically on the memmory using pointers, but I keep receiving the error messages:
|122|error: invalid conversion from 'void*' to 'int**'|
|124|error: invalid conversion from 'void*' to 'int*'|
Here is my code, I can't see what I'm doing wrong... this "void*" conversion does not make sense for me...
int i,j;
int **a;
int c = 2;
/* Form the matrix */
a = malloc((nxy+1)*sizeof(int *));
for (i=0;i<=nxy;i++)
a[i] = malloc((nxy+1)*sizeof(int));
for (i=0;i<=nxy;i++)
for (j=0;j<=nxy;j++)
a[i][j] = 0;
You are compiling your program with a C++ compiler. You have two choices:
malloc().If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With