I have to create a program using list and strings with functions:
(a) Functions to insert, remove, empty, display one line.
(b) Function to display all current lines (special case if the editor is empty) (c) Function to swap two lines (Assuming they exist)
(d) Functions to search a particular word on the editor
(e) Function (Non-member) to display a menu with all these operations
Note: The program will have the specific features:
1. A line in the list should not be more than 40 characters. (Declared as a constant) 2. Program should continue (in a loop) until user chooses to quit from the menu.
3. The maximum number of lines should be 10 (Declared as a constant)
4. If the list is full display the message: <List Full>
5. If the list is empty display the message: <List Empty>
6. The program should NOT delete from empty list and NOT add to a full list.
**Im stuck removing the lines the user inputed**
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
#include <iostream>
#include <list>
#include <string>
#include <ctime>
using namespace std;
void insert(list<string> &);
//void remove(list<string> &, string);
void empty(list<string> &);
void display(list<string> &);
const int Max = 10;
int main ()
{
list<string> lista;
list<string>::iterator iter;
//Inserts
string line;
for (int i=1; i <= 10; i++)
{
cout << "Enter Line " << i << endl;
cin >> line;
lista.push_back(line);
}
//Displays
for (iter=lista.begin(); iter!=lista.end(); ++iter)
cout << endl << *iter;
//Remove
int Remover;
for (int k=0; k<10; k++)
{
cout << "Enter the line number you want to delete:";
cin >> Remover;
lista.remove(iter??); //not sure how to move certain line
Remover = 0;
}
return 0;
}
|
I'm making everything in main first so i know everything works and then after i will put in each function in the prototypes.