Trouble with array sorting
I'm working on teaching myself a little more about classes. I have a basic idea and I'd like to complicate things a little. I know, I know.. "Why the heck would you do that?" So I can learn basically.
Anyway, i'm going to post this script i'm working on. What I'm doing is collecting first name, last name and age. They get stored in an array and when the user is ready, they are printed to the screen.
I'm having the hardest time figuring out how to ..
[list=a][*]Split this into 2 files (a .cpp file and a .h file)[*]give the user the option to sort the output by name or age[/list=a]
Here's my code..
Thanks in advance everyone.
using namespace std;
char firstName ;
char lastName ;
int getData(NameDataSet& nds)
cout << "\nEnter first name: ";
cin >> nds.firstName;
if ((strcmp(nds.firstName, "exit") == 0) || (strcmp(nds.firstName, "EXIT") == 0))
cout << "Enter last name: ";
cin >> nds.lastName;
cout << "Enter age: ";
cin >> nds.age;
void displayData(NameDataSet& nds)
cout << nds.firstName << " " << nds.lastName << " " << nds.age << "\n";
int main(int nArg, char* pszArgs)
cout << "Read first, last and age\n" << "Enter 'exit' for first name to exit\n";
int index = 0;
cout << "\nInformation: \n";
for (int i = 0; i < index; i++)