I need to take in a string up to 25 characters and output them in alphabetical order (case insensitive) according to the ASCII table. I have got them sorted, but I don't know how to make the case not matter.
examples
#?34trp ===> #34?prt
I am good ===> _ _adgImoo
aBA bCB ===> _aABbBC
For example, my code would only output the last example ===> _ABCabc. I know I could change them all to capitals and then sort, but I don't know a way to change them back into lower case if there is more than one of them.
Heres the code I have written:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char s1[25];
char temp;
int i, j;
gets(s1);
printf(" \n %s \n", s1);
for(j=0; s1[j]!= '\0'; j++)
{
for(i=0;s1[i+1]!= '\0'; i++)
{
if (s1[i]>s1[i+1])
{
temp=s1[i];
s1[i]=s1[i+1];
s1[i+1]=temp;
}
}
j++;
}
printf(" \n %s \n", s1);
return (0);
}
Thanks for the time,
Paul