I've encountered a problem where my array of structs didn't get assigned with value when I assign them value in a function. Here are the struct declarations:
typedef struct{
int length;
int width;
char texture;
int xpos;
int ypos;
}prop_info;
typedef struct{
int init_xpos;
int init_ypos;
int index;
prop_info prop[100];
}room_info;
And here are the functions:
void info_setup(room_info room,int init_xpos,int init_ypos,int index)
{
room.init_xpos=init_xpos;
room.init_ypos=init_ypos;
room.index=index;
}
void prop_setup(room_info room,int prop_index,int length,int width,char texture,int xpos,int ypos)
{
room.prop[prop_index].length=length;
room.prop[prop_index].width=width;
room.prop[prop_index].texture=texture;
room.prop[prop_index].xpos=xpos;
room.prop[prop_index].ypos=ypos;
}
room_info room_lobby;
void init_rooms()
{
info_setup(room_lobby,0,0,0);
prop_setup(room_lobby,0,1,1,'X',5,5);
}
And when I use the "init_rooms()" function in the main function:
int main()
{
init_rooms();
printf("%d",room_lobby.prop[0].xpos);
}
The printf only outputs a 0, and if I try to print out the "room_lobby.prop[0].texture", which is a char, it will only print a space when it should print a X. Thanks in advance!