diff options
| author | Connor McDowell <[email protected]> | 2024-02-21 16:51:29 -0800 |
|---|---|---|
| committer | Connor McDowell <[email protected]> | 2024-02-21 16:51:29 -0800 |
| commit | 2f564c37810887b388bacd7d4fff2f438b0e4a67 (patch) | |
| tree | 83db4e8145c05861a992a6bcd8fe5c322bb011c4 /Project1/contacts.cpp | |
| parent | gunna call it and talk with prof during office hours (diff) | |
| download | archived-homework-6-connormcdowell275-2f564c37810887b388bacd7d4fff2f438b0e4a67.tar.xz archived-homework-6-connormcdowell275-2f564c37810887b388bacd7d4fff2f438b0e4a67.zip | |
doubling working now
Diffstat (limited to 'Project1/contacts.cpp')
| -rw-r--r-- | Project1/contacts.cpp | 52 |
1 files changed, 31 insertions, 21 deletions
diff --git a/Project1/contacts.cpp b/Project1/contacts.cpp index 4c9814b..e542d64 100644 --- a/Project1/contacts.cpp +++ b/Project1/contacts.cpp @@ -116,33 +116,43 @@ contact contact_double(contact*& newContact, size_t& MAX, size_t t) //supposedly doubles length. doesn't 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]; + //for (auto a = 0u; a < MAX; ++a) + //{ + // doubleContact[a].a = newContact[a].a; + // doubleContact[a].id = newContact[a].id; + // doubleContact[a].count = newContact[a].count; + // doubleContact[a].Name[25] = newContact[a].Name[25]; + // doubleContact[a].Email[100] = newContact[a].Email[100]; + // doubleContact[a].StreetAddress[35] = newContact[a].StreetAddress[35]; + // doubleContact[a].City[30] = newContact[a].City[30]; + // doubleContact[a].State[3] = newContact[a].State[3]; + // doubleContact[a].Zip = newContact[a].Zip; + // cout << "List number: " << doubleContact[a].id << endl; + // cout << "name: " << doubleContact[a].Name << endl; + // cout << "Email: " << doubleContact[a].Email << endl; + // cout << "Address: " << doubleContact[a].StreetAddress << endl; + // cout << "city: " << doubleContact[a].City << endl; + // cout << "state: " << doubleContact[a].State << endl; + // cout << "Zip: " << doubleContact[a].Zip << endl; + //} + //newContact = doubleContact; + //delete[] doubleContact; + ////delete[] newContact; + //MAX = MAX * 2; + ////printAll(&doubleContact[MAX], MAX); + ////printAll(&newContact[MAX], MAX); + //return newContact[MAX]; + contact* doubleContact = new contact[MAX * 2]; for (auto a = 0u; a < MAX; ++a) { - doubleContact[a].a = newContact[a].a; - doubleContact[a].id = newContact[a].id; - doubleContact[a].count = newContact[a].count; - doubleContact[a].Name[30] = newContact[a].Name[30]; - doubleContact[a].Email[100] = newContact[a].Email[100]; - doubleContact[a].StreetAddress[35] = newContact[a].StreetAddress[35]; - doubleContact[a].City[30] = newContact[a].City[30]; - doubleContact[a].State[3] = newContact[a].State[3]; - doubleContact[a].Zip = newContact[a].Zip; - cout << "List number: " << doubleContact[a].id << endl; - cout << "name: " << doubleContact[a].Name << endl; - cout << "Email: " << doubleContact[a].Email << endl; - cout << "Address: " << doubleContact[a].StreetAddress << endl; - cout << "city: " << doubleContact[a].City << endl; - cout << "state: " << doubleContact[a].State << endl; - cout << "Zip: " << doubleContact[a].Zip << endl; + doubleContact[a] = newContact[a]; } + delete[] newContact; newContact = doubleContact; - delete[] doubleContact; - //delete[] newContact; MAX = MAX * 2; - //printAll(&doubleContact[MAX], MAX); - //printAll(&newContact[MAX], MAX); - return newContact[MAX]; + return newContact[MAX - 1]; } size_t max_double(size_t MAX) |