好的,所以我被要求使用函数 inver_caps 在 C 中反转大写。我的功能可以正常工作并正确打印新字母,但我不知道为什么主要它不能正确打印?
有任何想法吗?
void invert_caps (char letter);
int main(void){
char lettermain;
printf("Enter a letter: ");
scanf(" %c", &lettermain);
invert_caps(lettermain);
printf("The invert of the letter is %c \n", lettermain);
system("PAUSE");
return 0;
}
void invert_caps (char letter){
printf("\nletter is %d\n",letter); /*this was used for debugging*/
if ((int)letter >=65 && (int)letter<=90){
letter = (int)letter+32;
}else{
letter = (int)letter - 32;
}
printf("\nnew letter is %d or %c\n",letter, letter); /*this was used for debugging*/
return letter;
}