This is for a simple game and I am trying to learn how to apply C++ in an existing project (that's how I learn best), I have experience programming in C# and other high level languages so it is quite new to me still. So I have this list of races:
const char* Races[] = {
"Demon",
"Human",
"Elf",
"Orc",
"Aliens"
};
At one point I receive the registration of a user and a race is selected. I save away all the information of the user to a struct and I want to save the full name of the race to this struct as well.
struct User_t {
unsigned int RaceID;
char Race[16];
};
The following code is what I got to put the values inside the struct:
User_t User;
User.RaceID = 3;
strcpy(User.Race, Races[User.RaceID]);
This, however, does not work. This is part of a game and the exception handling is horrible (it basically crashes the game without any error visible). I am trying to figure out what I am doing wrong. Any suggestions, perhaps suggestions on other things as well?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire