diff options
Diffstat (limited to 'Project1/contacts.cpp')
| -rw-r--r-- | Project1/contacts.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/Project1/contacts.cpp b/Project1/contacts.cpp index 828bef5..162d30b 100644 --- a/Project1/contacts.cpp +++ b/Project1/contacts.cpp @@ -110,20 +110,27 @@ void printAll(contact newContact[], size_t MAX) } } -void contact_double(contact*& newContact, size_t& MAX, size_t t) +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 * 2; ++a) + for (auto a = 0u; a < MAX; ++a) { doubleContact[a] = newContact[a]; } - delete[] newContact; newContact = doubleContact; + delete[] doubleContact; MAX = MAX * 2; - //return newContact[MAX]; + printAll(&newContact[MAX], MAX); + return newContact[MAX]; +} + +size_t max_double(size_t MAX) +{ + MAX = MAX * 2; + return MAX; } void delete_contact(contact newContact[]) |