1.在ASCLL码表中
大写字母和小写字母相差32,所以直接对字符加减32即可。
#include<stdio.h>
int main()
{
char n;
scanf("%c",&n);
printf("%c",n-32);
return 0;
}
2.toupper()
tolower()
char ch2=toupper(98);
printf("%c\n,ch2);
char ch3=toupper("b");
printf("%c\n,ch3);
char ch4=toupper("ab");
printf("%c\n,ch4);
B
B
ab
toupper()可以直接接收整形数据即字符的ASCLL值作为参数,然后返回相应大写字母的ASCLL值。
toupper()函数的参数的整形只能识别一个字节的整形,超过一个字节,发生整形截断。返回的是截断后的原数据,不会返回转换后大写的数据。