Stucture with array of pointers in C

Posted by MVTCplusplus on Stack Overflow See other posts from Stack Overflow or by MVTCplusplus
Published on 2012-09-08T21:07:14Z Indexed on 2012/09/08 21:38 UTC
Read the original article Hit count: 151

Filed under:
|
|

What's wrong with this? Can I have an array of pointers to SDL_Surfaces in a struct in C?

typedef struct {
    int next_wheel;
    int pos_X;
    int pos_Y;
    int front_wheel_pos_X;
    int front_wheel_pos_Y;
    int velocity;
    int rear_wheel_pos_X;
    int rear_wheel_pos_Y;
    SDL_Surface* body;
    SDL_Surface* rear_wheel[9];
    SDL_Surface* front_wheel[9];
} mars_rover;

...

mars_rover* init_rover() {
    mars_rover* rover = (mars_rover*)malloc(sizeof(mars_rover) + sizeof(SDL_Surface) * 19);
    ...
    return rover;
}

int main() {
    mars_rover* rover = init_rover();
...
}

© Stack Overflow or respective owner

Related posts about c

    Related posts about pointers