tolower ()-toupper ()- 转换字符大小写
格式
#include <ctype.h>
int tolower(int C);
int toupper(int c);语言级别
ANSI
线程安全
是
语言环境敏感
这些函数的行为可能受当前语言环境的 LC_CTYPE 类别影响。 有关更多信息,请参阅 了解 CCSID 和语言环境。
描述
tolower() 函数将大写字母 C 转换为相应的小写字母。
toupper() 函数将小写字母 c 转换为相应的大写字母。
返回值
这两个函数都返回已转换的字符。 如果字符 c 没有相应的小写或大写字符,那么函数返回 c 不变。
示例
此示例使用
toupper() 和 tolower() 函数来更改代码 0 与代码 7f之间的字符。#include <stdio.h>
#include <ctype.h>
int main(void)
{
int ch;
for (ch = 0; ch <= 0x7f; ch++)
{
printf("toupper=%#04x\n", toupper(ch));
printf("tolower=%#04x\n", tolower(ch));
putchar('\n');
}
}