diff options
| author | Connor McDowell <[email protected]> | 2024-02-19 17:59:21 -0800 |
|---|---|---|
| committer | Connor McDowell <[email protected]> | 2024-02-19 17:59:21 -0800 |
| commit | 37e8217e006fc390ea50a65e2c45d8430c535dcb (patch) | |
| tree | 3ca9b1ff441adfd718528788344b73686d134951 /Project1/program.cpp | |
| parent | char strings set up (diff) | |
| download | homework-6-connormcdowell275-37e8217e006fc390ea50a65e2c45d8430c535dcb.tar.xz homework-6-connormcdowell275-37e8217e006fc390ea50a65e2c45d8430c535dcb.zip | |
working on doubles
Diffstat (limited to 'Project1/program.cpp')
| -rw-r--r-- | Project1/program.cpp | 34 |
1 files changed, 16 insertions, 18 deletions
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 |