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;
}