I've been trying to get this function to work for a while now but it's not happening.. Basically I need to make the function sort the strings in an alphabetical order.. This is what I have so far but when I run this function the name of the first person disappears.. I think it has something to do with my constant I have it set to 50 but it's actually supposed to be a user entered value... it's supposed to be the same value as total and I don't know how to make them the same value.... And also I need to link string x, string y, and int z together so that the names and ages don't get messed up
void sort_x (string x [], string y [], int z [], int total)
{
int index; // current spot in array being compared
string temp; // temporary value for swapping
bool swapped; // true if a swap was done, else false
swapped = true;
// continue making passes through the array
// until no swaps have been done on a pass
while (swapped)
{
swapped = false;
// do one pass
// step through array, swap pairs that are
// out of order
for (index = 0; index < total; index++)
{
// if the elements are out of order swap
if (x [index] > x [index + 1])
{
temp = x [index];
x [index] = x [index + 1];
x [index + 1] = temp;
swapped = true;
}
}
}
}