I'm coding a game right now and everything works great that i want to have working right now, but there's a minor bug that i know of.
this is that when the player enters their name, and the name has spaces, the code just closes.
here's the part of code:
char name [40]; // lets the players name be up to 40 characters
int main (){
cout << "Hello, Welcome." << endl; // title screen
cout << "What do you want your name to be?" << endl;
cin >> name;
system ("cls");
cout << "Congratulations " << name << " What do you want your class to be?" << endl; // this will determine base stats
cout << "1. Warrior" << endl;
cout << "2. Mage" << endl;
cout << "3. Healer" << endl;
cin >> typeofclass;
if (typeofclass == 1){
system ("cls");
yourclass = 'Warrior';
cout << "You have chosen to be a Warrior.\n" << endl; // gives stats for this person
health = 500;
mana = 10;
str = 25;
def = 25;
}
else if (typeofclass == 2){
system ("cls");
yourclass = 'Mage';
cout << "You have chosen to be a Mage.\n" << endl;
health = 250;
mana = 50;
str = 10;
def = 10;
}
else if (typeofclass == 3){
system ("cls");
yourclass = 'Healer';
cout << "You have chosen to be a Healer.\n";
health = 250;
mana = 40;
str = 5;
def = 5;
}
else {
cout << "Sorry, thats not a right number, please try again." << endl;
}
cout << "Your Stats are:" << endl << endl;
cout << "Health " << health << endl << endl << "Mana " << mana << endl << endl;
cout << "Strength " << str << endl << endl << "Defense " << def << endl << endl;
cout << "Press Enter to continue.\n \n";
cin.ignore();
cin.get();
mainmenu();
cin.ignore();
cin.get();
}