Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main() {
- string test;
- string test2;
- string varSelect; //used to control which text will be repeated
- bool varSuccess = false; //controls if the variable was correctly input, initially false to start loop
- bool loop = true; //controls if we want to keep looping the request to print either string
- cout << "Please enter a some text: " << endl;
- getline(cin, test);
- cin.clear();
- cout << "Please enter another text: " << endl;
- getline(cin, test2);
- cin.clear();
- while (loop = true) {
- while (varSuccess = false) {
- cout << "If you would like the first text, type a, if you would like the second, type b" << endl;
- getline(cin, varSelect);
- cin.clear();
- cout << varSelect[0] << endl;
- if ((varSelect.length() == 1) && (varSelect[0]> 96) && (varSelect[0] < 100)) {
- varSuccess = true;
- }
- }
- if (varSelect[0] == 97) {
- cout << test << endl;
- }
- if (varSelect[0] == 98) {
- cout << test2 << endl;
- }
- if (varSelect[0] == 99) {
- loop = false;
- }
- }
- cout << "See you next time" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement