I've inputted a sting (a name) and also inputted a number. However, when this runs the second time (Twice per program, usually), the second person's stats do not appear when couted. Can someone help?
BTW, is there a way to use a CLS-like command (like in QBASIC and DOS) in C++?Code:#include <iostream.h> main() { int Loop; do { char OneName[21], TwoName[21], Choice; int OneHealth, TwoHealth; cout << '\n'; cout << "What is Player 1's name? (20 char. max) "; cin.get(OneName, 21); cin.ignore(5, '\n'); do { cout << '\n' << "How much life does " << OneName << " have? (Range: 150-500) "; cin >> OneHealth; } while ((OneHealth < 150) || (OneHealth > 500)); cout << '\n'; cout << '\n'; cout << "What is Player 2's name? (20 char. max) "; cin.get(TwoName, 21); cin.ignore(5, '\n'); do { cout << '\n' << "How much life does " << TwoName << " have? (Range: 150-500) "; cin >> TwoHealth; } while ((TwoHealth < 150) || (TwoHealth > 500)); cout << '\n'; cout << OneName << " has " << OneHealth << " health and " << TwoName << " has " << " health." << endl; cout << "Is this correct? (Y/N) "; cin >> Choice; if ((Choice == 'Y') || (Choice == 'y')) Loop = 10; } while (Loop != 10); return 0; }



LinkBack URL
About LinkBacks


