Hey I got this loop that I want to loop forever unless the user types Exit. This is my current code; when C++ builds the program, it starts up the command prompt, and it's totally blank. Nothing but a cursor.
VB Code:
int i = 0; int a = 0; while (i == a); { cout <<"The armory trainer behind the counter speaks:\n"; cout <<"Armory Trainer: Welcome to the armory. Enter the number\n of the item you would" <<" like to buy:\n#1 Helmet = 200g\n#2 Shield = 500g\n#3 Armor = 900g\n" <<"#4 Dagger = 10g\n#5 Scimetar = 400g\n#6 ShortSword = 1000g\n" <<"#7 LongSword = 2000g\n#8 Exit\n\nArmory Trainer: So, what will it be?"; cin >> item; if (item == Helmet) { Shelmet -= 1; cout <<"You got a helmet."; plyrGold -= 200; } else if (item == Shield) { Sshield -= 1; cout <<"You receive a shield."; plyrGold -= 500; } else if (item == Armor) { Sarmor -= 1; cout <<"Wow! You got some heavy duty Armor"; plyrGold -= 900; } else if (item == Dagger) { Sdagger -= 1; cout <<"You got a dagger."; plyrGold -= 10; } else if (item == Scimetar) { Sscimetar -= 1; cout <<"You have received a Scimetar"; plyrGold -= 400; } else if (item == Shortsword) { Sshortsword -= 1; cout <<"Wow! You got a Shortsword."; plyrGold -= 1000; } else if (item == Longsword) { Slongsword -= 1; cout <<"Amazing! You got an awsome Longsword!"; plyrGold -= 2000; } else if (item == Exit) { return; } else { cout <<"The item you have asked for is one we \n" <<"don't carry."; } }
Thanks!
Ríçk




Eat long and prosper! 
Reply With Quote