diff options
| author | Connor McDowell <[email protected]> | 2024-02-19 17:04:17 -0800 |
|---|---|---|
| committer | Connor McDowell <[email protected]> | 2024-02-19 17:04:17 -0800 |
| commit | 5205d3d77bb3327af401952692a859f7c87882f2 (patch) | |
| tree | c9f754b2177bc87c8aa64fbcc0e83cdcaad0726d | |
| parent | working on doubling the size (diff) | |
| download | homework-6-connormcdowell275-5205d3d77bb3327af401952692a859f7c87882f2.tar.xz homework-6-connormcdowell275-5205d3d77bb3327af401952692a859f7c87882f2.zip | |
char strings set up
| -rw-r--r-- | Project1/Contacts.h | 10 | ||||
| -rw-r--r-- | Project1/contacts.cpp | 28 |
2 files changed, 19 insertions, 19 deletions
diff --git a/Project1/Contacts.h b/Project1/Contacts.h index 923c404..a6a0691 100644 --- a/Project1/Contacts.h +++ b/Project1/Contacts.h @@ -9,11 +9,11 @@ struct contact { int id = 0; int count = 0; - char Name[25] = {}; - char Email[100] = {}; - char StreetAddress[35] = {}; - char City[30] = {}; - char State[3] = {}; + char Name[25]{}; + char Email[100]{}; + char StreetAddress[35]{}; + char City[30]{}; + char State[5]{}; int Zip = 0; }; diff --git a/Project1/contacts.cpp b/Project1/contacts.cpp index 5925152..0dcead9 100644 --- a/Project1/contacts.cpp +++ b/Project1/contacts.cpp @@ -26,19 +26,19 @@ char addNew(contact newContact[], size_t MAX, int t) { for (int i = t; i < MAX; i++) { - cout << "Please enter all inputs as english characters with underscores (_) for spaces" << endl; newContact[i].id = i + 1; newContact[i].count = t; + cout << "Please enter each piece of information when you are prompted to" << endl; cout << "enter name: " << endl; - cin >> newContact[i].Name; + cin.getline(newContact[i].Name, 25); cout << "enter Email: " << endl; - cin >> newContact[i].Email; + cin.getline(newContact[i].Email, 100); cout << "enter Street Address: " << endl; - cin >> newContact[i].StreetAddress; + cin.getline(newContact[i].StreetAddress, 35); cout << "enter city: " << endl; - cin >> newContact[i].City; - cout << "enter State: " << endl; - cin >> newContact[i].State; + cin.getline(newContact[i].City, 30); + cout << "enter State as two letter abbreviation: " << endl; + cin.getline(newContact[i].Name, 5); cout << "Please enter the next value as a series of numbers" << endl; cout << "enter Zip: " << endl; cin >> newContact[i].Zip; @@ -64,18 +64,18 @@ void update(struct contact newContact[], size_t MAX) int t = c - 1; for (int i = t; i < MAX;) { - cout << "Please enter all inputs as english characters with underscores (_) for spaces" << endl; + cout << "Please enter each piece of information when you are prompted to" << endl; newContact[i].id = c; cout << "enter name: " << endl; - cin >> newContact[i].Name; + cin.getline(newContact[i].Name, 25); cout << "enter Email: " << endl; - cin >> newContact[i].Email; + cin.getline(newContact[i].Email, 100); cout << "enter Street Address: " << endl; - cin >> newContact[i].StreetAddress; + cin.getline(newContact[i].StreetAddress, 35); cout << "enter city: " << endl; - cin >> newContact[i].City; - cout << "enter State: " << endl; - cin >> newContact[i].State; + cin.getline(newContact[i].City, 30); + cout << "enter State as two letter abbreviation: " << endl; + cin.getline(newContact[i].Name, 5); cout << "Please enter the next value as a series of numbers" << endl; cout << "enter Zip: " << endl; cin >> newContact[i].Zip; |