Hi guys I've run into a problem,for some reason a blank string is being printed or you could also say nothing is being printed when I try to print out the string,this only occurs when I include a capital letter in the string such as acB if I type acb it sorts and prints them with no problems,I added a continue statement in to the for loop because I thought this would skip the rest of the code and go to the next iteration if that block of code got executed but to no avail anyway here is my code.
void order(char *str,int size){
bool sorted = false;
while(!sorted){
sorted = true;
for(int i = 0; i < size-1; i++){
if(str[i] >= 'A' && str[i] <= 'Z'){
if((str[i+1])-32 < str[i]){
char temp2 = str[i];
str[i] = str[i+1];
str[i+1] = temp2;
sorted = false;
continue;
}
}
if(str[i+1] < str[i]){
char temp = str[i];
str[i] = str[i+1];
str[i+1] = temp;
sorted = false;
}
}
}
}
int main()
{
char str[] = "aCb";
int size = sizeof(str) / sizeof(char);
order(str,size-1);
cout << str << endl;
}