Why? I added a function to test things and it's now repeating once and automatically assumes I entered something other than y, or n.
Code:#include <iostream> #include <string> using namespace std; int squared(int s) { return s * 2; } int main() { top: system("CLS"); cout << "What integer do you want squared? "; int x; cin >> x; cout << squared(x) << endl; string quitKey = "y"; do { topOfLoop: cout << "Do you wish to quit? y/n "; getline(cin, quitKey); if (quitKey == "y") return 1; if (quitKey == "n") goto top; else cout << "What? "; goto topOfLoop; } while (quitKey != "y"); return 0; }




Reply With Quote