I have a struct:
struct foo
{
  void *param;
};
void main(){
  foo object;
}
I need to make object.param point to a dynamically allocated 2D array.
I know this will obviously not work:
//CASE 1
pixel **buf = (pixel**)malloc(16*sizeof(pixel*));
for(int i=0; i<16;i++)
   buf[i] = (pixel*)malloc(16*sizeof(pixel));
object.param = (void **)buf
This works:
//CASE 2
pixel buf[16][16];
object.param = (void *)buf;
My question is:
- In case 2 why is bufinterpreted as a pointer of typepixel(when in factbufstorespixel*) which allows it to be cast to avoid*?
- How do I make case 1 work?
 
     
     
    