diff options
| author | Yana Blashchishina <[email protected]> | 2024-02-19 17:51:22 -0800 |
|---|---|---|
| committer | Yana Blashchishina <[email protected]> | 2024-02-19 17:51:22 -0800 |
| commit | 20670c71efb6a6dd08f96d0000bd2ef34096fd25 (patch) | |
| tree | 87927800cda749c8437942f288c7ef0b5679c3f4 /Homework6 | |
| parent | contacts.h fixed (diff) | |
| download | homework-6-yanablash-20670c71efb6a6dd08f96d0000bd2ef34096fd25.tar.xz homework-6-yanablash-20670c71efb6a6dd08f96d0000bd2ef34096fd25.zip | |
error in program.cpp
Diffstat (limited to 'Homework6')
| -rw-r--r-- | Homework6/Homework6/contacts.cpp | 6 | ||||
| -rw-r--r-- | Homework6/Homework6/program.cpp | 7 |
2 files changed, 9 insertions, 4 deletions
diff --git a/Homework6/Homework6/contacts.cpp b/Homework6/Homework6/contacts.cpp index c4ee25c..23b4790 100644 --- a/Homework6/Homework6/contacts.cpp +++ b/Homework6/Homework6/contacts.cpp @@ -15,11 +15,10 @@ void addContact(Contact contacts[], int& numContacts,int& arraySize) { newContacts[i] = contacts[i]; } delete[] contacts; - contacts = newContacts; } - Contact& newContact = contacts[numContacts]; + Contact& newContact = contacts[numContacts]; cout << "Enter Name: "; cin >> newContact.Name; @@ -39,6 +38,7 @@ void addContact(Contact contacts[], int& numContacts,int& arraySize) { cout << "Enter Zip Code: "; cin >> newContact.Zip; + ++numContacts; } @@ -97,7 +97,7 @@ void printContact(const Contact contacts[], int numContacts) { } -void deleteContact(const Contact contacts[], int& numContacts) { +void deleteContact(Contact contacts[], int& numContacts) { printContact(contacts, numContacts); if (numContacts > 0) { diff --git a/Homework6/Homework6/program.cpp b/Homework6/Homework6/program.cpp index 530021e..9b44f6e 100644 --- a/Homework6/Homework6/program.cpp +++ b/Homework6/Homework6/program.cpp @@ -21,7 +21,8 @@ int main() { cout << "1. Add New Contact "; cout << "2. Update Contact "; cout << "3. Print All Contacts "; - cout << "4. Exit "; + cout << "4. Delete contact "; + cout << "5. Exit "; int option; @@ -43,6 +44,10 @@ int main() { break; case 4: + deleteContact(contacts, numContacts); + break; + + case 5: cout << "Exiting"; return 0; default: |