diff options
| author | Connor McDowell <[email protected]> | 2024-02-18 16:08:27 -0800 |
|---|---|---|
| committer | Connor McDowell <[email protected]> | 2024-02-18 16:08:27 -0800 |
| commit | 7addf3cf043f1fc00fd8a641ccf65aa13b2fef47 (patch) | |
| tree | 225a16ff4f875ea4ae796e44a093dd895b39b11e | |
| parent | its fixed ???? testing (diff) | |
| download | homework-5-connormcdowell275-7addf3cf043f1fc00fd8a641ccf65aa13b2fef47.tar.xz homework-5-connormcdowell275-7addf3cf043f1fc00fd8a641ccf65aa13b2fef47.zip | |
got moving through the list working, but now print is broken;
| -rw-r--r-- | Project1/Contacts.h | 5 | ||||
| -rw-r--r-- | Project1/contacts.cpp | 58 | ||||
| -rw-r--r-- | Project1/program.cpp | 5 |
3 files changed, 38 insertions, 30 deletions
diff --git a/Project1/Contacts.h b/Project1/Contacts.h index 60e4dcb..a7d5dda 100644 --- a/Project1/Contacts.h +++ b/Project1/Contacts.h @@ -8,11 +8,12 @@ struct contact { int id = 0; + int count = 0; char Name[25] = {}; char Email[100] = {}; char StreetAddress[35] = {}; char City[30] = {}; - char State[2] = {}; + char State[3] = {}; int Zip = 0; }; @@ -21,7 +22,7 @@ struct contact int menu(); -char addNew(contact newContact[], size_t MAX); +char addNew(contact newContact[], size_t MAX, int t); void update(contact newContact[], size_t MAX); diff --git a/Project1/contacts.cpp b/Project1/contacts.cpp index dbb5a23..99db58d 100644 --- a/Project1/contacts.cpp +++ b/Project1/contacts.cpp @@ -22,34 +22,27 @@ int menu() return c; } -char addNew(contact newContact[], size_t MAX) +char addNew(contact newContact[], size_t MAX, int t) { - - int i = 0; - int c = 0; - cin >> c; - if (c == 1) + for (int i = t; i < MAX; i++) { - cout << "works!" << endl; - for (int i = 0; i < MAX; i++) - { - newContact[i].id = i + 1; - cout << "enter name: " << endl; - cin >> newContact[i].Name; - cout << "enter Email: " << endl; - cin >> newContact[i].Email; - cout << "enter Street Address: " << endl; - cin >> newContact[i].StreetAddress; - cout << "enter city: " << endl; - cin >> newContact[i].City; - cout << "enter State: " << endl; - cin >> newContact[i].State; - cout << "enter Zip: " << endl; - cin >> newContact[i].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; + newContact[i].id = i + 1; + cout << "enter name: " << endl; + cin >> newContact[i].Name; + cout << "enter Email: " << endl; + cin >> newContact[i].Email; + cout << "enter Street Address: " << endl; + cin >> newContact[i].StreetAddress; + cout << "enter city: " << endl; + cin >> newContact[i].City; + cout << "enter State: " << endl; + cin >> newContact[i].State; + cout << "enter Zip: " << endl; + cin >> newContact[i].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; return 0; } // print contact i @@ -92,12 +85,23 @@ void printAll(contact newContact[], size_t MAX) { for (int i = 0; i < MAX; ++i) { - cout << newContact[i].id << endl; + /*for (int t = -1; t < newContact[i].id;) { + break; + }*/ + if (newContact[i].id < 0) { + if (newContact[i].id >= MAX){ + if (newContact[i].id == 0) { + break; + } + } + } + cout << "List number: " << newContact[i].id << endl; 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 << "city: " << newContact[i].City << endl; cout << "state: " << newContact[i].State << endl; cout << "Zip: " << newContact[i].Zip << endl; + } } diff --git a/Project1/program.cpp b/Project1/program.cpp index 1d21308..4336284 100644 --- a/Project1/program.cpp +++ b/Project1/program.cpp @@ -27,6 +27,7 @@ int main() { constexpr size_t MAX = 10; int O = 1; + int t = 0; contact newContact[MAX]; while (O == 1) { @@ -40,7 +41,9 @@ int main() //c = menu(); if (c == 1) { - addNew(&newContact[MAX], MAX); + addNew(&newContact[MAX], MAX, t); + ++t; + cout << t << endl; } if (c == 2) { |