现在的位置: 首页 > 综合 > 正文

大小写字母转换方法

2013年08月30日 ⁄ 综合 ⁄ 共 205字 ⁄ 字号 评论关闭
#include <stdio.h>
/*
大写字母A的ascii码为41h		01000001
小写字母a的ascii码为61h		01100001
利用这个特性可以很方便的进行大小写字母的转换
*/
#define Upper(x) ((x)&(0xCF))
#define Low(x) ((x)|(0x20))

void main()
{
	printf("%c\n",Upper('a'));
	printf("%c\n",Low('A'));
}

抱歉!评论已关闭.