I'm trying to create a function that sorts strings, and I've made a function that I think should work, but the toupper() function doesn't seem to be having any effect. Is there something I am missing here?
void selectionSort(string array[], int size) {
int startScan, minIndex;
string minValue;
for(startScan=0; startScan<(size-1); startScan++) {
minIndex = startScan;
minValue = array[startScan];
for(int index=startScan+1; index<size; index++) {
string word = array[index];
toupper(word[0]);
if(array[index] < minValue) {
minValue = array[index];
minIndex = index;
}
}
array[minIndex] = array[startScan];
array[startScan] = minValue;
}
}
toupper()returns.toupper, why dump the entire sort function on the unsuspecting reader? Also, you probably shoukkd be usingstd::vectorandstd::sortin real code.