From 2b40c135bdbda403394d4970d8eee44532a3dc0d Mon Sep 17 00:00:00 2001 From: Connor McDowell Date: Mon, 19 Feb 2024 16:57:46 -0800 Subject: working on doubling the size --- Project1/program.cpp | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'Project1/program.cpp') diff --git a/Project1/program.cpp b/Project1/program.cpp index 4e62543..6bf362d 100644 --- a/Project1/program.cpp +++ b/Project1/program.cpp @@ -10,25 +10,12 @@ using std::cin; using std::cout; using std::endl; - -// -// -//int main() -//{ -// -// -// -// -// -// return 0; -//} - int main() { - constexpr size_t MAX = 10; + size_t MAX = 3; int O = 1; int t = 0; - contact newContact[MAX]; + contact* newContact = new contact[MAX]; while (O == 1) { int c = 0; @@ -43,7 +30,21 @@ int main() { addNew(&newContact[MAX], MAX, t); ++t; - //cout << t << endl; + cout << t << endl; + cout << "enter full length of array" << endl; + cin >> t; + if (t >= 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; + } } if (c == 2) { -- cgit v1.2.3