diff options
Diffstat (limited to 'Homework6ReeceWarner/contacts.cpp')
| -rw-r--r-- | Homework6ReeceWarner/contacts.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/Homework6ReeceWarner/contacts.cpp b/Homework6ReeceWarner/contacts.cpp index ab29692..6f56563 100644 --- a/Homework6ReeceWarner/contacts.cpp +++ b/Homework6ReeceWarner/contacts.cpp @@ -1,6 +1,6 @@ #include "contacts.h" -//contact contacts[MAX] = {}; + contact emptycontact[MAX] = {}; //this is what I am comparing strings with in the print function int numberofcontacts = 0; contact* contacts = new contact[MAX]; @@ -39,7 +39,6 @@ contact InputNewContact(const size_t size) cin.get(contacts->Zip, 50, '\n'); return *contacts; - } void printcontacts() { @@ -53,7 +52,7 @@ void printcontacts() result = strcmp(existingcontacts.Name, empty.Name); //Compares the cString with an empty one, when it is equal, it prints nothing!!! if (result == 0) { - Prompts(" "); + Prompts(""); cout << endl; } else @@ -71,6 +70,7 @@ void printcontacts() contact UpdateContact() { printcontacts(); + int i = ReadInt("Which contact would you like to update?"); contacts[i] = InputNewContact(MAX); @@ -81,17 +81,14 @@ contact UpdateContact() return updatedcontacts; } -contact DeleteContactInformation() +contact* DeleteContactInformation() { printcontacts(); - - contact deletedcontact = contacts[ReadInt("Which contact would you like to delete?")]; - deletedcontact = {'\0'}; - for (int i = 0u; i < numberofcontacts; i++) //shifts deleted contact to the top - { - contacts[i] = contacts[i + 1]; - } + + contact* deletedcontact = &contacts[ReadInt("Which contact would you like to delete?")]; + + *deletedcontact = { '\0' }; return deletedcontact; @@ -195,6 +192,7 @@ int ReadInt(const char* Prompt) } return Value; } + void DeleteEverything() { delete[] contacts; |