How do I access the members of an opaque data struct in C when it is passed by double reference to a set function?

231 Views Asked by At

I'm new to C and I'm working with an opaque data structure passed by double reference. I've declared the struct prototype in cars.h as typedef struct car car. In cars.c I then go on to define the struct with the following members:

struct car{char model;
           int year; };

I have a function to set the year of the car:

void set_year(car **my_car , int year){
      *my_car->year = 1998;  
}

However, I can't see the members of the struct even though set_year and car are both defined in car.c. How do I access these members correctly?

*EDIT

Here is the resolution to what my question was asking:

void set_year(car **my_car , int year){
      (*my_car)->year = 1998;  
}
0

There are 0 best solutions below