diff options
| author | Connor McDowell <[email protected]> | 2024-02-18 14:10:00 -0800 |
|---|---|---|
| committer | Connor McDowell <[email protected]> | 2024-02-18 14:10:00 -0800 |
| commit | 0701f875cc5cf358b644dd9b53f462d12968ea7d (patch) | |
| tree | 8b06381c8a96214471c3f94a566c16c2a699fe31 /Project1 | |
| parent | couts added to help guide inputs (WIP) (diff) | |
| download | homework-5-connormcdowell275-0701f875cc5cf358b644dd9b53f462d12968ea7d.tar.xz homework-5-connormcdowell275-0701f875cc5cf358b644dd9b53f462d12968ea7d.zip | |
still sorting out errors
Diffstat (limited to 'Project1')
| -rw-r--r-- | Project1/Contacts.h | 6 | ||||
| -rw-r--r-- | Project1/contacts.cpp | 54 | ||||
| -rw-r--r-- | Project1/program.cpp | 17 |
3 files changed, 42 insertions, 35 deletions
diff --git a/Project1/Contacts.h b/Project1/Contacts.h index df5416e..76b66cf 100644 --- a/Project1/Contacts.h +++ b/Project1/Contacts.h @@ -19,11 +19,11 @@ struct contact int menu(); -char addNew(contact* newContact[]); +char addNew(contact* newContact, size_t MAX); -void update(contact* newContact[]); +void update(contact* newContact, size_t MAX); -void printAll(contact* newContact[]); +void printAll(contact newContact, size_t MAX); diff --git a/Project1/contacts.cpp b/Project1/contacts.cpp index 036f899..6f29040 100644 --- a/Project1/contacts.cpp +++ b/Project1/contacts.cpp @@ -24,7 +24,7 @@ int menu() return c; } -char addNew(contact* newContact[]) +char addNew(contact* newContact, size_t MAX) { int i = 0; @@ -33,24 +33,24 @@ char addNew(contact* newContact[]) if (c == 1) { cout << "works!" << endl; - for (int i = 0; i < 10; i++) + for (int i = 0; i < MAX; i++) { - newContact[i]->id = i + 1; + newContact->id = i + 1; cout << "enter name: " << endl; - cin >> newContact[i]->Name; + cin >> newContact->Name; cout << "enter Email: " << endl; - cin >> newContact[i]->Email; + cin >> newContact->Email; cout << "enter Street Address: " << endl; - cin >> newContact[i]->StreetAddress; + cin >> newContact->StreetAddress; cout << "enter city: " << endl; - cin >> newContact[i]->City; + cin >> newContact->City; cout << "enter State: " << endl; - cin >> newContact[i]->State; + cin >> newContact->State; cout << "enter Zip: " << endl; - cin >> newContact[i]->Zip; + cin >> newContact->Zip; break; } - cout << newContact[i]->Name << "\n" << newContact[i]->Email << "\n" << newContact[i]->StreetAddress << "\n" << newContact[i]->City << "\n" << newContact[i]->State << "\n" << newContact[i]->Zip << endl; + //cout << newContact[i]->Name << "\n" << newContact[i]->Email << "\n" << newContact[i]->StreetAddress << "\n" << newContact[i]->City << "\n" << newContact[i]->State << "\n" << newContact[i]->Zip << endl; } return 0; } @@ -62,40 +62,40 @@ char addNew(contact* newContact[]) // state // zip -void update(contact* newContact[]) +void update(struct contact* newContact, size_t MAX) { int i = 0; int c = 0; cin >> i; i = i - 1; - newContact[i]->id; + newContact->id; cin >> c; - if (c = 1) + if (c == 1) { cout << "enter name: " << endl; - cin >> newContact[i]->Name; + cin >> newContact->Name; cout << "enter Email: " << endl; - cin >> newContact[i]->Email; + cin >> newContact->Email; cout << "enter Street Address: " << endl; - cin >> newContact[i]->StreetAddress; + cin >> newContact->StreetAddress; cout << "enter city: " << endl; - cin >> newContact[i]->City; + cin >> newContact->City; cout << "enter State: " << endl; - cin >> newContact[i]->State; + cin >> newContact->State; cout << "enter Zip: " << endl; - cin >> newContact[i]->Zip; + cin >> newContact->Zip; } } -void printAll(contact* newContact[]) +void printAll(contact newContact, size_t MAX) { - for (int i = 0; i < newContact[i]->id; ++i) + for (int i = 0; i < MAX; ++i) { - cout << "name: " << newContact[i]->Name << endl; - cout << "Email: " << newContact[i]->Email << endl; - cout << "Address: " << newContact[i]->StreetAddress << endl; - cout << "city" << newContact[i]->City << endl; - cout << "state: " << newContact[i]->State << endl; - cout << "Zip: " << newContact[i]->Zip << endl; + cout << "name: " << newContact.Name << endl; + cout << "Email: " << newContact.Email << endl; + cout << "Address: " << newContact.StreetAddress << endl; + cout << "city" << newContact.City << endl; + cout << "state: " << newContact.State << endl; + cout << "Zip: " << newContact.Zip << endl; } } diff --git a/Project1/program.cpp b/Project1/program.cpp index c97ba49..135546c 100644 --- a/Project1/program.cpp +++ b/Project1/program.cpp @@ -25,23 +25,30 @@ using std::endl; int main() { + constexpr size_t MAX = 10; int O = 1; - contact newContact[10]; + contact newContact; while (O == 1) { int c = 0; - c = menu(); + cout << "1. Enter a name\n"; + cout << "2. Delete a name\n"; + cout << "3. List the file\n"; + cout << "4. Quit\n"; + cout << "\nEnter your choice: "; + cin >> c; + //c = menu(); if (c == 1) { - addNew(&newContact[]); + addNew(&newContact, MAX); } if (c == 2) { - update(&newContact[]); + update(&newContact, MAX); } if (c == 3) { - printAll(&newContact[]); + printAll(newContact, MAX); } if (c == 4) { |