Hello there. Ive been doing some c++ in dev-c++. I started a month ago, taught myself from books and playing around with written code, the basics and i now know
computer function
computer sience and variabeldefinition (char, int, short, long, float, bool, double, long double, \n, \t, \", \\, \b.
Algorithm,pseudocode,
byte, bit, etc etc
many choiceoperators (this is important so you know what way to reply)
anyhow, after learning all that i started skipping through sides of the book looking for the command to go back in a program, the reason i want to know this is because im trying to make a text based game to help my learning of c++, i will keep on learning by this book (wich i have) while making this game, ive come about 100 codes forward, lets skip to my question:
i want to know how to back up in a program
for exampel: if the program is giving 3 option at the start for example: start, option, info. If someone chooses info i dont know how to help the get back to the choices. Another question is when i come to the end of the game or wherever ive place system("CLS"); i need to post system("PAUSE"); so i doesnt automaticly skip. however, wherever i post this it says press any button to skip, how can i prevent this from showing up whilst maintaining the "non skipping". I'm 13 years old and im from sweden so try to explain the code with very easy language.
this is part of the code (a part where i use the system("PAUSE");) please help.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
system("PAUSE");
system("CLS");
cout << "What class do you want to be?" << endl;
cout << "Healer?" << endl;
cout << "Fighter?" << endl;
cout << "Magician?" << endl;
cout << "Ranger?" << endl;
cin >> Class;
system("CLS");
if (Class == "Ranger" || Class == "ranger"){
cout << "You have chosen the class " << Class;
cout << " is this the class you want?\n";
}
if (Class == "Healer" || Class == "healer"){
cout << "You have chosen the class " << Class;
cout << " is this the class you want?\n";
}
if (Class == "Fighter" || Class == "fighter"){
cout << "You have chosen the class " << Class;
cout << " is this the class you want?\n";
}
if (Class == "Magician" || Class == "magician"){
cout << "You have chosen the class " << Class;
cout << " is this the class you want?\n";
}
cin >> YesorNo;
system("CLS");
if (YesorNo == "Yes" || YesorNo == "yes") {
cout << "Good \n";
}
else { // Find a way to go back steps
cout << "Sorry, Restart to go back! \n";
}
system("PAUSE");
return 0;
}
| |