aboutsummaryrefslogtreecommitdiff
path: root/Homework6ReeceWarner/contacts.cpp
diff options
context:
space:
mode:
authorrPatrickWarner <[email protected]>2024-02-19 21:36:41 -0800
committerrPatrickWarner <[email protected]>2024-02-19 21:36:41 -0800
commit40c6679b526c7d0ce5de35cdac350e84d9576355 (patch)
tree057c420f77c1225d980ace93e4b49e8828deee31 /Homework6ReeceWarner/contacts.cpp
parentchanges (diff)
downloadhomework-6-reecepwarner-main.tar.xz
homework-6-reecepwarner-main.zip
completedHEADmain
Diffstat (limited to 'Homework6ReeceWarner/contacts.cpp')
-rw-r--r--Homework6ReeceWarner/contacts.cpp20
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;