#include <iostream>
#include <cstring> // I am using the C++ strings library, not character arrays.
using namespace std;
void getName(string);
void giveName(string);
string namesArray[10];
int main(){
int getOption = 0;
int loopValue = 0;
int loopValue2 = 0;
do{
cout << "Please enter a 1 if you want to enter names, a 2 if you wish to find a name, or a 0 if you want to exit." << endl;
do{
cin >> getOption;
if (getOption == 0){
cout << "Goodbye." << endl;
return 0;
}
if (getOption < 0 || getOption > 2){
cout << "Please enter a valid selection." << endl;
loopValue2 = 0;
}
else{
if (getOption == 1){
getName(namesArray[10]);
loopValue2 = 1;
}
else{
giveName(namesArray[10]);
loopValue2 = 1;
}
}
}while(loopValue2 = 0);
} while(loopValue = 0);
}
void getName(string namesArray[]){
string firstName, lastName;
for(int i = 0; i < 10; i++){
cout << "When you are done entering names, please type exit for the next person's first name." << endl;
cout << "Please enter person number " << i++ << "'s first name." << endl;
cin >> firstName;
if (firstName == "exit"){
i = 10;
break;
}
cout << "Please enter person number " << i++ << "'s last name." << endl;
cin >> lastName;
lastName = " " + lastName;
namesArray[i] = firstName + lastName; // Concat to give the full name in 1 part of the array.
}
}