diff options
| author | Connor McDowell <[email protected]> | 2024-02-21 20:24:48 -0800 |
|---|---|---|
| committer | Connor McDowell <[email protected]> | 2024-02-21 20:24:48 -0800 |
| commit | 9c707a5fca27593aaf1ab4e203e060dd65473373 (patch) | |
| tree | 197f3363ff133f1abba32bfdd2f5bc8370ae8bcc /Project1 | |
| parent | so close to being done oh my god (diff) | |
| download | homework-6-connormcdowell275-9c707a5fca27593aaf1ab4e203e060dd65473373.tar.xz homework-6-connormcdowell275-9c707a5fca27593aaf1ab4e203e060dd65473373.zip | |
ITS DONE :D
Diffstat (limited to 'Project1')
| -rw-r--r-- | Project1/contacts.cpp | 71 |
1 files changed, 31 insertions, 40 deletions
diff --git a/Project1/contacts.cpp b/Project1/contacts.cpp index 3d61730..295df0d 100644 --- a/Project1/contacts.cpp +++ b/Project1/contacts.cpp @@ -208,20 +208,20 @@ void delete_contact(contact newContact[], size_t MAX) cout << "The list of contacts and their names will now print" << endl; for (auto i = 0u; i < MAX; i++) { - if (newContact[i].id == 0) { - break; - } - if (newContact[i].id < 0) { - break; - } - if (newContact[i].id > MAX) { - break; - } - //if (newContact[i].a == 1) - //{ - // break; - //} - cout << "Id number: " << newContact[i].id << " is under the name: " << newContact[i].Name << endl; + if (newContact[i].id == 0) { + break; + } + if (newContact[i].id < 0) { + break; + } + if (newContact[i].id > MAX) { + break; + } + //if (newContact[i].a == 1) + //{ + // break; + //} + cout << "Id number: " << newContact[i].id << " is under the name: " << newContact[i].Name << endl; //size_t delete_choice = 0; //cout << "\n"; //cin.ignore(1000, '\n'); @@ -235,34 +235,25 @@ void delete_contact(contact newContact[], size_t MAX) // break; //} } - for (int y = 0u; y < MAX; y++) + for (auto i = 0u; i < MAX; i++) { - size_t delete_choice = 0; - cout << "\n"; - cin.ignore(1000, '\n'); - cout << "Enter the id number of the contact you'd like to delete" << endl; - cin >> delete_choice; - newContact[delete_choice].a = 1; - cout << "Contact number: " << newContact[delete_choice].id << " deleted" << endl; - newContact[delete_choice + 1].id = newContact[delete_choice + 1].id - 1; - break; + size_t delete_choice = 0; + cout << "\n"; + cin.ignore(1000, '\n'); + cout << "Enter the id number of the contact you'd like to delete" << endl; + cin >> delete_choice; + if (delete_choice != newContact[i].id) + { + i = i + 1; + } + if (delete_choice == newContact[i].id) + { + newContact[i].a = 1; + cout << "Contact number: " << newContact[i].id << " deleted" << endl; + newContact[i + 1].id = newContact[i + 1].id - 1; + break; + } } - - //for (auto i = 0u; i < MAX; i++) - //{ - // size_t delete_choice = 0; - // cout << "\n"; - // cin.ignore(1000, '\n'); - // cout << "Enter the id number of the contact you'd like to delete" << endl; - // cin >> delete_choice; - // if (delete_choice == newContact[delete_choice].id) - // { - // newContact[i].a = 1; - // cout << "Contact number: " << newContact[i].id << " deleted" << endl; - // newContact[i + 1].id = newContact[i + 1].id - 1; - // break; - // } - //} //cout << "The list of contacts and their names will now print" << endl; // for (auto i = 0u; i <= MAX; i++) // { |