I’m not new to C but I just found out a problem which I have to deal with.
How do I access the member of a struct that is a pointer to another struct?
ex.
typdef struct {
int points;
} tribute;
typedef struct {
int year;
tribute *victor;
} game;
int main(){
tribute myVictor;
myVictor.points = 10;
game myGame;
myGame.year = 1994; // Runs fine
myGame.victor = myVictor; // I want to point the victor member of the game struct to
//myVictor object... But it gives me an error
}
How could I correct this? I know that I should’ve made the myGame variable as a pointer.. but I’m asking if I can do this in a normal struct variable.
Try: