diff options
| author | Connor McDowell <[email protected]> | 2024-02-19 19:55:46 -0800 |
|---|---|---|
| committer | Connor McDowell <[email protected]> | 2024-02-19 19:55:46 -0800 |
| commit | 599c5b9fddb1fdf72946379ea345977778e7753b (patch) | |
| tree | 2a63f13fba6f6b66597be3b145d87253d2695214 | |
| parent | still testing the doubling. (diff) | |
| download | homework-6-connormcdowell275-599c5b9fddb1fdf72946379ea345977778e7753b.tar.xz homework-6-connormcdowell275-599c5b9fddb1fdf72946379ea345977778e7753b.zip | |
i love it when i have a fuckin workin program but then oooo you have to double it and nOTHING WORKS anymore. ive been doin this shit all fuckin weekend i havent seen the sun in days.
| -rw-r--r-- | Project1/Contacts.h | 4 | ||||
| -rw-r--r-- | Project1/contacts.cpp | 21 | ||||
| -rw-r--r-- | Project1/program.cpp | 17 |
3 files changed, 20 insertions, 22 deletions
diff --git a/Project1/Contacts.h b/Project1/Contacts.h index d44e6c5..32da79c 100644 --- a/Project1/Contacts.h +++ b/Project1/Contacts.h @@ -7,7 +7,7 @@ struct contact { - int id = 0; + size_t id = 0; int count = 0; char Name[25]{}; char Email[100]{}; @@ -26,7 +26,7 @@ char addNew(contact newContact[], size_t MAX, size_t t); void update(contact newContact[], size_t MAX); -void printAll(contact newContact[], size_t MAX); +void printAll(contact newContact[], size_t MAX, size_t Cont_list_lenth); void contact_double(contact*& newContact, size_t MAX, size_t t); diff --git a/Project1/contacts.cpp b/Project1/contacts.cpp index 4f2ec9e..ee1641d 100644 --- a/Project1/contacts.cpp +++ b/Project1/contacts.cpp @@ -24,10 +24,11 @@ int menu() char addNew(contact newContact[], size_t MAX, size_t t) { - for (size_t i = t; i < MAX; i++) + size_t a = t - 1; + for (size_t i = a ;; i++) { - newContact[i].id = i + 1; - newContact[i].count = t; + newContact[i].id = i; + newContact[i].count = a - 1; cin.ignore(1000, '\n'); cout << "Please enter each piece of information when you are prompted to" << endl; cout << "enter name: " << endl; @@ -85,22 +86,22 @@ void update(struct contact newContact[], size_t MAX) } } -void printAll(contact newContact[], size_t MAX) +void printAll(contact newContact[], size_t MAX, size_t Cont_list_lenth) { - for (int i = 0; i < MAX; ++i) + for (size_t i = 0; i < Cont_list_lenth; ++i) { /*for (int t = -1; t < newContact[i].id;) { break; }*/ - if (newContact[i].id == 0) { + /*if (newContact[i].id == 0) { break; - } + }*/ if (newContact[i].id < 0) { break; } - if (newContact[i].id > MAX) { - break; - } + //if (newContact[i].id > Cont_list_lenth) { + // break; + //} cout << "List number: " << newContact[i].id << endl; cout << "name: " << newContact[i].Name << endl; diff --git a/Project1/program.cpp b/Project1/program.cpp index 19ef0d2..0709b6c 100644 --- a/Project1/program.cpp +++ b/Project1/program.cpp @@ -15,27 +15,25 @@ constexpr size_t MAX = 3; int main() { int O = 1; + constexpr size_t MAX = 3; size_t Cont_list_lenth = 0; - contact* newContact = new contact[MAX]; + contact* newContact = new contact[3]; while (O == 1) { + cout << Cont_list_lenth << endl; int c = 0; 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 << "5. Quit\n"; cout << "\nEnter your choice: " << endl; cin >> c; //c = menu(); if (c == 1) { + Cont_list_lenth++; addNew(&newContact[Cont_list_lenth], MAX, Cont_list_lenth); - if (Cont_list_lenth >= MAX) - { - contact_double(newContact, MAX, Cont_list_lenth); - } - } if (c == 2) { @@ -43,7 +41,7 @@ int main() } if (c == 3) { - printAll(&newContact[Cont_list_lenth], MAX); + printAll(&newContact[Cont_list_lenth], MAX, Cont_list_lenth); } if (c == 4) { @@ -54,7 +52,6 @@ int main() delete[] newContact; return 0; } - ++Cont_list_lenth; - cout << Cont_list_lenth << endl; + } }
\ No newline at end of file |