diff options
| author | rPatrickWarner <[email protected]> | 2024-02-19 21:36:41 -0800 |
|---|---|---|
| committer | rPatrickWarner <[email protected]> | 2024-02-19 21:36:41 -0800 |
| commit | 40c6679b526c7d0ce5de35cdac350e84d9576355 (patch) | |
| tree | 057c420f77c1225d980ace93e4b49e8828deee31 | |
| parent | changes (diff) | |
| download | homework-6-reecepwarner-main.tar.xz homework-6-reecepwarner-main.zip | |
| -rw-r--r-- | Homework6ReeceWarner/contacts.cpp | 20 | ||||
| -rw-r--r-- | Homework6ReeceWarner/contacts.h | 3 | ||||
| -rw-r--r-- | Homework6ReeceWarner/program.cpp | 1 |
3 files changed, 11 insertions, 13 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; diff --git a/Homework6ReeceWarner/contacts.h b/Homework6ReeceWarner/contacts.h index da1b48e..48b151b 100644 --- a/Homework6ReeceWarner/contacts.h +++ b/Homework6ReeceWarner/contacts.h @@ -16,7 +16,6 @@ using std::endl; constexpr size_t MAX_STREAM_SIZE = numeric_limits<streamsize>::max(); constexpr size_t MAX = 3; - struct contact { char Name[50] = {}; @@ -37,7 +36,7 @@ void Prompts(const char* phrase); void OutputContacts(char* arrays, const char* prompt, int x); void printcontacts(); - +contact* DeleteContactInformation(); const size_t DoubleArraySize(const size_t& size); void DeleteEverything(); #endif diff --git a/Homework6ReeceWarner/program.cpp b/Homework6ReeceWarner/program.cpp index 770f20b..b86d207 100644 --- a/Homework6ReeceWarner/program.cpp +++ b/Homework6ReeceWarner/program.cpp @@ -6,6 +6,7 @@ int main() { + menu(); return 0; |