Possible Duplicate:
Why does C++ require a cast for malloc() but C doesn’t?
This particular piece of code runs fine in C, but gives compilation error when compiled as a C++ program.
#include<stdio.h>
#include<stdlib.h>
int main(){
int (*b)[10];
b = calloc(20, sizeof(int));
return 0;
}
The error in C++ compilation is:
test.cpp: In function ‘int main()’:
test.cpp:9:28: error: invalid conversion from ‘void*’ to ‘int (*)[10]’ [-fpermissive]
Any idea what might be the reason?