diff options
| author | Connor McDowell <[email protected]> | 2024-02-17 19:41:57 -0800 |
|---|---|---|
| committer | Connor McDowell <[email protected]> | 2024-02-17 19:41:57 -0800 |
| commit | 8001ead9eb01b3afe6e8e805d838f4d8ba384ce3 (patch) | |
| tree | cd248b80cc50a02f5d30f0862f26a6c5762f62a8 | |
| parent | currently what im working with (diff) | |
| download | homework-5-connormcdowell275-8001ead9eb01b3afe6e8e805d838f4d8ba384ce3.tar.xz homework-5-connormcdowell275-8001ead9eb01b3afe6e8e805d838f4d8ba384ce3.zip | |
finally getting into the groove of this assignment
| -rw-r--r-- | Project1/Contacts.h | 18 | ||||
| -rw-r--r-- | Project1/contacts.cpp | 107 | ||||
| -rw-r--r-- | Project1/program.cpp | 52 |
3 files changed, 127 insertions, 50 deletions
diff --git a/Project1/Contacts.h b/Project1/Contacts.h index bf58cf2..a6b9497 100644 --- a/Project1/Contacts.h +++ b/Project1/Contacts.h @@ -1,9 +1,24 @@ #ifndef CONTACTS_HEADER_H #define CONTACTS_HEADER_H + + // functions -char addNew(); +struct contact +{ + char Name[25] = {}; + char Email[100] = {}; + char StreetAddress[35] = {}; + char City[30] = {}; + char State[2] = {}; + int Zip = 0; +}; + + +int menu(); + +char addNew(contact newContact); void update(); @@ -11,5 +26,4 @@ void printAll(); void exit(); - #endif CONTACTS_HEADER_H
\ No newline at end of file diff --git a/Project1/contacts.cpp b/Project1/contacts.cpp index bafd648..f932281 100644 --- a/Project1/contacts.cpp +++ b/Project1/contacts.cpp @@ -6,59 +6,80 @@ using std::cin; using std::cout; using std::endl; -using std::list; -using std::vector; +constexpr int MAX = 100; -struct contact +int menu() { - int id = 0; - char Name[25] = {}; - char Email[100] = {}; - char StreetAddress[35] = {}; - char City[30] = {}; - char State[2] = {}; - int Zip = 97034; -}; - -contact myArrays(contact newContact) -{ - int i = 0; - std::list<contact> myList(100, newContact); - for (auto i = 0; i < 100; i++) - { - newContact.id = i; - addNew(); - myList.push_back(newContact); - } - cout << newContact.id << endl; - return newContact; + int c; + + cout << "1. Enter a name\n"; + cout << "2. Delete a name\n"; + cout << "3. List the file\n"; + cout << "4. Quit\n"; + do { + cout <<"\nEnter your choice: "; + cin >> c; + } while (c < 0 || c>4); + return c; } -char addNew() +char addNew(contact newContact) { - // prompt user input w/o spaces - - + + int i = 0; + int c = 0; + cin >> c; + if (c == 1) + { + cout << "works!" << endl; + for (int i = 0; i < 10; i++) + { + cin >> newContact[i].Name; + cin >> newContact[i].Email; + cin >> newContact[i].StreetAddress; + cin >> newContact[i].City; + cin >> newContact[i].State; + 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; + } +} - contact newContact[i]; - cin >> newContact[i].Name; - cout << newContact[i].Name << endl; - cin >> newContact[i].Email; - cout << newContact[i].Email << endl; - cin >> newContact[i].StreetAddress; - cout << newContact[i].StreetAddress << endl; - cin >> newContact[i].City; - cout << newContact[i].City << endl; - cin >> newContact[i].State; - cout << newContact[i].State << endl; - cin >> newContact[i].Zip; - cout << newContact[i].Zip << endl; +//struct contact_list +//{ +// contact contact[MAX_CONTACTS]; +// int count; +//}; +//int contacts_insert_new(contact_list contacts, contact newContact) +//{ +// memcpy(&contacts->contact[contacts->count++], newContact); +// +//} - return 0; -} +//char addNew() +//{ +// contact newContact; +// cin >> newContact.Name; +// cout << newContact.Name << endl; +// cin >> newContact.Email; +// cout << newContact.Email << endl; +// cin >> newContact.StreetAddress; +// cout << newContact.StreetAddress << endl; +// cin >> newContact.City; +// cout << newContact.City << endl; +// cin >> newContact.State; +// cout << newContact.State << endl; +// cin >> newContact.Zip; +// cout << newContact.Zip << endl; +// +// +// +// return 0; +//} //for (auto const& i : name) //{ diff --git a/Project1/program.cpp b/Project1/program.cpp index e893d7f..e5cd30a 100644 --- a/Project1/program.cpp +++ b/Project1/program.cpp @@ -10,11 +10,53 @@ using std::cin; using std::cout; using std::endl; -int main() -{ - addNew(); - +// +// +//int main() +//{ +// +// +// +// +// +// return 0; +//} - return 0; +int main() +{ + contact newContact[10]; + //int choice = menu(); + //int i = 0; + //int c = 0; + //cin >> c; + //if (c == 1) + //{ + // cout << "works!" << endl; + // for (int i = 0; i < 10; i++) + // { + // cin >> newContact[i].Name; + // cin >> newContact[i].Email; + // cin >> newContact[i].StreetAddress; + // cin >> newContact[i].City; + // cin >> newContact[i].State; + // 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; + //} + //for (int i = 0; i < 10; i++) + //{ + // cin >> newContact[i].Name; + // cin >> newContact[i].Email; + // cin >> newContact[i].StreetAddress; + // cin >> newContact[i].City; + // cin >> newContact[i].State; + // cin >> newContact[i].Zip; + //} + /*cin >> i; + 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 << "new name"; + cin >> newContact[2].Name; + cout << newContact[2].Name;*/ }
\ No newline at end of file |