Allocating a dynamic SDL_Surface array and populate in c

I don’t know why this code doesn’t work. I’m trying to create a dynamic SDL_Surface array. I would appreciate your help.

SDL_Surface *brickim;
SDL_Surface* load_map(char *map_name , int tran );

void load_level(int stage){
int n;
input.N=10;
...
SDL_Surface *brickim=(SDL_Surface *)malloc(sizeof(SDL_Surface)*input.N);
for (n=0;n < input.N;n++) brickim[n]=load_map("brick1.bmp",1); /*Line 34*/
}

>
Error compiler 
gcc -I "/usr/include/SDL" -c levels.c
levels.c: In function ‘load_level’:
levels.c:34:39: error: incompatible types when assigning to type ‘SDL_Surface’ from type ‘struct SDL_Surface *’
   for (n=0;n < input.N;n++) brickim[n]=load_map("brick1.bmp",1);

The load_map function and the file char “brick1.bmp” are working properly with other SDL_Surfaces which are not array form.


Source: gcc

Leave a Reply