I'm making a programm that, if the user inputs a lowercase character, the programm generates it's character in uppercase, and the opposite too. I'm using a function in order convert the character into lowercase or uppercase based on ASCII table. Lowercase to uppercase is being converted correctly, but uppercase to lowercase is not. I dunno if I'm messing it up:
char changeCapitalization(char n)
{
//uppercase to lowercase
if(n>=65 && n<=90)
n=n+32;
//lowercase to uppercase
if(n>= 97 && n<=122)
n=n-32;
return n;
}
Aucun commentaire:
Enregistrer un commentaire