From 37e8217e006fc390ea50a65e2c45d8430c535dcb Mon Sep 17 00:00:00 2001 From: Connor McDowell Date: Mon, 19 Feb 2024 17:59:21 -0800 Subject: working on doubles --- Project1/program.cpp | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'Project1/program.cpp') diff --git a/Project1/program.cpp b/Project1/program.cpp index 6bf362d..74fce1e 100644 --- a/Project1/program.cpp +++ b/Project1/program.cpp @@ -10,11 +10,12 @@ using std::cin; using std::cout; using std::endl; +constexpr size_t MAX = 3; + int main() { - size_t MAX = 3; int O = 1; - int t = 0; + size_t Cont_list_lenth = 0; contact* newContact = new contact[MAX]; while (O == 1) { @@ -22,29 +23,19 @@ int main() cout << "1. Enter a contact\n"; cout << "2. Update a contact\n"; cout << "3. print all contacts\n"; + cout << "4. Delete a contact\n"; cout << "4. Quit\n"; cout << "\nEnter your choice: " << endl; cin >> c; //c = menu(); if (c == 1) { - addNew(&newContact[MAX], MAX, t); - ++t; - cout << t << endl; - cout << "enter full length of array" << endl; - cin >> t; - if (t >= MAX) + addNew(&newContact[MAX], MAX, Cont_list_lenth); + if (Cont_list_lenth >= MAX) { - contact* doubleContact = new contact[MAX * 2]; - - for (newContact[t].count = t; t < MAX * 2;) - { - doubleContact[t] = newContact[t]; - } - delete[] newContact; - newContact = doubleContact; - MAX = MAX * 2; + contact_double(newContact, MAX, Cont_list_lenth); } + } if (c == 2) { @@ -56,7 +47,14 @@ int main() } if (c == 4) { - O = 0; + //work in progress + } + if (c == 5) + { + delete[] newContact; + return 0; } + ++Cont_list_lenth; + cout << Cont_list_lenth << endl; } } \ No newline at end of file -- cgit v1.2.3