diff options
Diffstat (limited to 'Project1/contacts.cpp')
| -rw-r--r-- | Project1/contacts.cpp | 58 |
1 files changed, 31 insertions, 27 deletions
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; + } } |