c - strcpy() only copying one string to a struct, but not the other -


i'll cut down bare basics, rest of code unnecessary. it's basic text adventure program.

// defines numeric values each room typedef enum {     kitchen,     pantry,     hallway_1,     hallway_2,     trolls_domain,     empty_room_1,     empty_room_2,     exit,     no_room } en_rooms;  // defines struct type store room data typedef struct room{     char name[50];     char desc[50]; // description } room;  // fills array r info on each room. void room_setup(room *r){     strcpy(r[kitchen].name, "kitchen");     strcpy(r[kitchen].desc, "this kitchen."); }  int main(void){     ...      room rooms[10];     room_setup(rooms); // fill rooms array info     en_rooms currentroom = kitchen; // set starting room kitchen      // main game loop     while(1){          ...          // print room name + description         printf("-- %s --\n", rooms[currentroom].name);         printf("%s\n", rooms[currentroom].desc);          ...     } } 

for whatever reason, output this:

-- rp@ -- kitchen. 

can me work out why strcpy() copy rooms description, not it's name properly?


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -