PROBLEM, PROBLEM, PROBLEM ...

The program use a circular linked list and data structures to store the tasks.
 Every task should include a task name, a name for the person assigned to it, and the deadline for the task.
 Variables should be dynamic and their sizes should be determined at runtime based on the length of user input.
 You should implement the following functions (with appropriate arguments and return types) for your structure: add(), remove(), search(), and list().
 The add()function should add tasks alphabetically by task name. You do not need to implement any file operations.
 The search() function should be able search for a task by the task assignee name or the task name.
 The list() function should print records to the screen in the order they appear in the circular linked list.
 You should successfully deallocate all of the allocated memory before termination of your program.
For this program here my code:
#include <iostream>
using namespace std;

struct Node{
int id;
string task;
string person;
string date;
Node *next;
};

void add(Node *&);
void search(Node *&);
void remove(Node *&);
void list(Node *&);

int main()
{
char command;
Node *lookedNode = NULL;

cout << "A: Add Task" << endl;
cout << "S: Search for Task" << endl;
cout << "L: List All Tasks" << endl;
cout << "R: Remove Task" << endl;
cout << "E: Exit" << endl;
cout << "Choose an operation: " << endl;
cin >> command;

while(command != 'E'){

switch(command)
{
case 'A':
add(lookedNode);
break;
case 'S':
search(lookedNode);
break;
case 'L':
list(lookedNode);
break;
case 'R':
remove(lookedNode);
break;
case 'E':
return 0;
default:
cout << "Your entry is invalid. Please try again." << endl;
break;
}

cout << "A: Add Task" << endl;
cout << "S: Search for Task" << endl;
cout << "L: List All Tasks" << endl;
cout << "R: Remove Task" << endl;
cout << "E: Exit" << endl;
cout << "Choose an operation: " << endl;
cin >> command;
}

return 0;
}

void add(Node *&firstLooked)
{
string taskName;
string personName;
string time;
Node *current = new Node;
Node *additive = new Node;
current = firstLooked;

cout << "Please enter the task: ";
getline(cin, taskName);
additive->task = taskName;
cout << "Please enter name of person who does the task: ";
getline(cin, personName);
additive->person = personName;
cout << "Please enter the deadline like this: dd.mm.year : ";
getline(cin, time);
additive->date = time;

if(firstLooked == NULL){
firstLooked = additive;
additive->next = firstLooked;
additive->id = 1;
}
else{
while((current->task) > (additive->task)){
current = current->next;
additive->id += 1;
}
additive->id += 1;
current->next = additive;
additive->next = firstLooked;
}

delete current;
cout << endl;
}

void search(Node *&firstLooked)
{
string desired;
Node *current = new Node;
current = firstLooked;

cout << "To search for a task, enter its task name or assigned name: " << endl;
getline(cin, desired);

if(current == NULL){
cout << "List is empty. There is not a node in the list." << endl;
return;
}
else{
if(((firstLooked->task) == desired) || ((firstLooked->person) == desired)){
cout << firstLooked->id << " - " << firstLooked->task << endl;
cout << firstLooked->person << " - " << firstLooked->person << endl;
}
while(current != firstLooked){
current = current->next;
if( ((current->task) == desired) || ((current->person) == desired)){
cout << current->id << " - " << current->task << endl;
cout << current->person << " - " << current->person << endl;
current = firstLooked;
}
}
}
delete current;
}

void remove(Node *&firstlooked)
{
int numberOfNode;
Node *current = new Node;
Node *prev = new Node;
current = firstlooked;

list(firstlooked);
cout << "There is not a node in the list to remove!" << endl;

if(current != NULL){
cout << "Choose the ID of the task you want to remove: ";
cin >> numberOfNode;
while(current != firstlooked){
prev->next = current;
current = current->next;
if(current->id == numberOfNode){
prev->next = current->next;
current = prev->next;
current == firstlooked;
}
}
}
delete current;
delete prev;
}

void list(Node *&firstLooked)
{
Node *current = new Node;
current = firstLooked;

if(current == NULL){
cout << "List is empty!\n";
return;
}
else{
cout << "All tasks are listed below: \n";
current = current->next;
while(current != firstLooked){
cout << current->id << "- " << current->task << endl;
cout << current->person << " - " << current->date << endl;
current = current->next;
}
}
}
This code include lots of error. An output of code:

A: Add Task
S: Search for Task
L: List All Tasks
R: Remove Task
E: Exit
Choose an operation:
A
Please enter the task: Please enter name of person who does the task: John
Please enter the deadline like this: dd.mm.year : 12.03.2014

A: Add Task
S: Search for Task
L: List All Tasks
R: Remove Task
E: Exit
Choose an operation:
A
Please enter the task: Please enter name of person who does the task: William
Please enter the deadline like this: dd.mm.year : 14.02.2014

A: Add Task
S: Search for Task
L: List All Tasks
R: Remove Task
E: Exit
Choose an operation:
L
All tasks are listed below:

Process returned -1073741819 (0xC0000005) execution time : 41.936 s
Press any key to continue.
Where are my mistakes and what are they? This code is my fisrt code about linked list. So ı cannot found mistakes easily. I would appreciate if you could help.
Is there anyone who can help?
Topic archived. No new replies allowed.