finished:
see if you can understand this let me know if you cant i can explain.
Code:
#include <string>
#include <iostream>
using namespace std;
void taskmanager();
main ()
{
taskmanager();
cout << "\nBye\n\n\n\n\n\nAll Code Copyright Patrick \n\n\nAll Rights Reserved\n";
return 0;
}
void taskmanager()
{
string task[40]; //for spaces to be allowed, must be a string
int input, num, i = 0;
bool exit = false; //becomes true when exit is selected
while (!exit)
{
cout << "\nHello \n This is your friendly task manager \n Select a command \n";
cout << "1) Add a task \n2) Read next on list\n3) Quit\n";
cin >> num; //enter selection
switch (num) //decides what to do for the number entered
{
case 1:
cout<< "\nOK, enter your task:\n ";
cin.get(); //must dump enter before filling string
getline( cin, task[i] ); //fills string using cin (keyboard)
i++;
break;
case 2:
if (i==0)
{
cout<<"\nSorry, no items to read\n";
input = 0;
}
//else is needed because if there is nothing there
//you dont want this to execute
else
{
cout << "\nDO THIS:\n";
cout << task[(i-1)];
input = 0;
}
break;
case 3:
exit = true; //if 3 is chosen than exit is true
break;
default:
cout << "Invalid Input"; //what happens if they enter 5? this does...
}
}
}