diff options
| -rw-r--r-- | Project1/Contacts.h | 2 | ||||
| -rw-r--r-- | Project1/contacts.cpp | 12 | ||||
| -rw-r--r-- | Project1/program.cpp | 30 |
3 files changed, 18 insertions, 26 deletions
diff --git a/Project1/Contacts.h b/Project1/Contacts.h index 32da79c..edeb2e0 100644 --- a/Project1/Contacts.h +++ b/Project1/Contacts.h @@ -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, size_t Cont_list_lenth); +void printAll(contact newContact[], size_t MAX); void contact_double(contact*& newContact, size_t MAX, size_t t); diff --git a/Project1/contacts.cpp b/Project1/contacts.cpp index ee1641d..dd7f0e8 100644 --- a/Project1/contacts.cpp +++ b/Project1/contacts.cpp @@ -24,11 +24,10 @@ int menu() char addNew(contact newContact[], size_t MAX, size_t t) { - size_t a = t - 1; - for (size_t i = a ;; i++) + for (size_t i = t ; i < MAX; i++) { - newContact[i].id = i; - newContact[i].count = a - 1; + newContact[i].id = i+1; + newContact[i].count = t; cin.ignore(1000, '\n'); cout << "Please enter each piece of information when you are prompted to" << endl; cout << "enter name: " << endl; @@ -86,9 +85,9 @@ void update(struct contact newContact[], size_t MAX) } } -void printAll(contact newContact[], size_t MAX, size_t Cont_list_lenth) +void printAll(contact newContact[], size_t MAX) { - for (size_t i = 0; i < Cont_list_lenth; ++i) + for (size_t i = 0; i < MAX; ++i) { /*for (int t = -1; t < newContact[i].id;) { break; @@ -123,5 +122,4 @@ void contact_double(contact*& newContact, size_t MAX, size_t t) } delete[] newContact; newContact = doubleContact; - }
\ No newline at end of file diff --git a/Project1/program.cpp b/Project1/program.cpp index 0709b6c..7f01a8f 100644 --- a/Project1/program.cpp +++ b/Project1/program.cpp @@ -10,48 +10,42 @@ using std::cin; using std::cout; using std::endl; -constexpr size_t MAX = 3; +//constexpr size_t MAX = 3; int main() { + constexpr size_t MAX = 10; int O = 1; - constexpr size_t MAX = 3; - size_t Cont_list_lenth = 0; - contact* newContact = new contact[3]; + int t = 0; + contact newContact[MAX]; 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 << "5. Quit\n"; + cout << "3. Delete a contact\n"; + cout << "4. 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); + addNew(&newContact[MAX], MAX, t); + ++t; + //cout << t << endl; } if (c == 2) { - update(&newContact[Cont_list_lenth], MAX); + update(&newContact[MAX], MAX); } if (c == 3) { - printAll(&newContact[Cont_list_lenth], MAX, Cont_list_lenth); - } - if (c == 4) - { - //work in progress + printAll(&newContact[MAX], MAX); } if (c == 5) { - delete[] newContact; - return 0; + O = 0; } - } }
\ No newline at end of file |