I am writing a program, for homework, that would rank 3 runners in 1st, 2nd and 3rd places based on their finish times. I need to bubble sort the names, but it fails. Here is what I have:
//Constants Used: const int iLength = 21; //20 Chars + 1 null terminator. //Variable Declaration Section: //3 char. variables to hold 3 user input. char cRunner1[iLength], cRunner2[iLength], cRunner3[iLength]; char cExtraName[iLength]; //1 extra name to help in the sorting.
Later I have:
cout << "Name of Runner number 1: "; cin.getline(cRunner1, iLength);
and then in an If Statement that swaps the values of the finishing times I have:
cExtraName = cRunner1; cRunner1 = cRunner2; Runner2 = cExtraName;
I am having 2 problems:
1st problem, if I enter a name < 20 characters the system hangs, and does not go any further from the cin.getline line.
2nd problem, there seems to be a data type issue when I am swapping the names to sort them.
Thanks in advance to any help.