/*
Simple Menu with 3 options.
1) Input string
2) Print string
3) Exit
*/
#include <iostream>
#include <string>
using namespace std;
int main()
{
//User is finished and while loop ends if variable running is not 1.
int running = 1;
string f = "";
while (running == 1)
{
cout << "Please enter either 1, 2, or 3 \n 1.) Type a sentence. \n 2.) Check last sentence typed. \n 3.) Exit Program.\n";
int input = 0;
cin >> input;
switch (input)
{
case 1: //Inputs user string and stores it.
cout << "Type whatever you want. \n";
cin >> f;
cout << "The sentence has been saved." << "\n";
break;
case 2: //Display last sentence from case 1
if (f == "" | f ==" ")
{
cout << "Nothing was last typed. \n";
break;
}
else
{
cout << "The last string entered was...\n" << f << "\n";
break;
}
case 3: //Exit
cout << "Exiting the program\n";
running = 0;
break;
}
}
//out of the loop
cout << "This is out of the loop.";
cin.get();
cin.get();
}