diff options
| author | Connor McDowell <[email protected]> | 2024-02-21 13:28:59 -0800 |
|---|---|---|
| committer | Connor McDowell <[email protected]> | 2024-02-21 13:28:59 -0800 |
| commit | fae782e95a133affd899bf3160b1a4d5e86d5965 (patch) | |
| tree | fba480a823b4088924c796b943b25f0e5379365d | |
| parent | still fuckin trying (diff) | |
| download | homework-6-connormcdowell275-fae782e95a133affd899bf3160b1a4d5e86d5965.tar.xz homework-6-connormcdowell275-fae782e95a133affd899bf3160b1a4d5e86d5965.zip | |
comments added. attempting new try to get doubling to work.
| -rw-r--r-- | Project1/Contacts.h | 2 | ||||
| -rw-r--r-- | Project1/contacts.cpp | 13 | ||||
| -rw-r--r-- | Project1/program.cpp | 14 |
3 files changed, 22 insertions, 7 deletions
diff --git a/Project1/Contacts.h b/Project1/Contacts.h index d1cfe61..220e0f8 100644 --- a/Project1/Contacts.h +++ b/Project1/Contacts.h @@ -30,4 +30,6 @@ void printAll(contact newContact[], size_t MAX); void contact_double(contact*& newContact, size_t& MAX, size_t t); +void delete_contact(contact newContact[]); + #endif CONTACTS_HEADER_H
\ No newline at end of file diff --git a/Project1/contacts.cpp b/Project1/contacts.cpp index 7db5b25..2e95c97 100644 --- a/Project1/contacts.cpp +++ b/Project1/contacts.cpp @@ -114,9 +114,11 @@ void printAll(contact newContact[], size_t MAX) void contact_double(contact*& newContact, size_t& MAX, size_t t) { + //supposedly doubles length. doesnt work. + //current ideas: add if loop to whole main with the id counter t and if length of newContact = max double the length. + //current problems: using const size_t max prevents editing size for the whole function, and it resets as soon as the while loop loops or leaves the scope of the if statement. contact* doubleContact = new contact[MAX * 2]; - size_t a = 0; - for (a = t, a < MAX * 2; ++a;) + for (auto a = 0u; a < MAX * 2; ++a) { doubleContact[a] = newContact[a]; } @@ -124,4 +126,11 @@ void contact_double(contact*& newContact, size_t& MAX, size_t t) newContact = doubleContact; MAX = MAX * 2; //return newContact[MAX]; +} + +void delete_contact(contact newContact[]) +{ + //Work in progress, add BOOL (0) to struct, when this is selected print id list with respective names + //then take input of id list number and set BOOL to 1 + //add to new part to addNew: if bool != 0 then copy and paste update code w/addNew couts }
\ No newline at end of file diff --git a/Project1/program.cpp b/Project1/program.cpp index 5dd1654..24a02ff 100644 --- a/Project1/program.cpp +++ b/Project1/program.cpp @@ -14,18 +14,18 @@ using std::endl; int main() { - size_t MAX = 3; int O = 1; - size_t t = 0; - contact* newContact = new contact[MAX]; while (O == 1) { + size_t MAX = 3; + size_t t = 0; + contact* newContact = new contact[MAX]; int c = 0; cout << "1. Enter a contact\n"; cout << "2. Update a contact\n"; cout << "3. print all contacts\n"; - cout << "3. Delete a contact\n"; - cout << "4. Quit\n"; + cout << "4. Delete a contact\n"; + cout << "5. Quit\n"; cout << "\nEnter your choice: " << endl; cin >> c; //c = menu(); @@ -42,6 +42,10 @@ int main() { printAll(&newContact[MAX], MAX); } + if (c == 4) + { + delete_contact(&newContact[MAX]); + } if (c == 5) { O = 0; |