大小写转换

#include <stdio.h>
#include <ctype.h>

/*
大小写转换的库函数:
int tolower(int c)
int toupper(int c)
*/

int my_tolower(unsigned char c)
{
	return (c + ('a' - 'A'));
}

int my_toupper(unsigned char c)
{
	return (c - ('a' - 'A'));
}


int main(void)
{

	printf("%c\n", my_tolower('G'));
	printf("%c\n", my_toupper('f'));

	printf("%c\n", tolower('G'));
	printf("%c\n", toupper('f'));

	return 0;
}

输出:

g
F
g
F

posted @ 2012-12-04 19:35  helloweworld  阅读(194)  评论(0编辑  收藏  举报