c语言toupper,toupper_字符串 | Strings_C_参考手册_非常教程

toupper

在头文件中定义

int toupper(int ch);

根据当前安装的C语言环境定义的字符转换规则,将给定的字符转换为大写字符。

在默认的“C”语言环境中,下面的小写字母abcdefghijklmnopqrstuvwxyz被替换为相应的大写字母ABCDEFGHIJKLMNOPQRSTUVWXYZ。

参数

CH

-

字符被转换。如果ch的值不能表示为unsigned char并且不等于EOF,则行为是未定义的。

返回值

如果在当前C语言环境中未列出大写版本,则ch或unmodified ch的大写版本。

#include

#include

#include

#include

int main(void)

{

/* In the default locale: */

unsigned char u;

for (unsigned char l=0; l

u = toupper(l);

if (l!=u) printf("%c%c ", l,u);

}

printf("\n\n");

unsigned char c = '\xb8'; // the character Ž in ISO-8859-15

// but ´ (acute accent) in ISO-8859-1

unsigned char c2 = c; // for printing

setlocale(LC_ALL, "en_US.iso88591");

printf("in iso8859-1, toupper('0x%x') gives 0x%x\n", c2, toupper(c));

setlocale(LC_ALL, "en_US.iso885915");

printf("in iso8859-15, toupper('0x%x') gives 0x%x\n", c2, toupper(c));

}

输出:

aA bB cC dD eE fF gG hH iI jJ kK lL mM nN oO pP qQ rR sS tT uU vV wW xX yY zZ

in iso8859-1, toupper('0xb8') gives 0xb8

in iso8859-15, toupper('0xb8') gives 0xb4

参考

C11标准(ISO / IEC 9899:2011): 7.4.2.2 toupper功能(p:204)

C99标准(ISO / IEC 9899:1999): 7.4.2.2 toupper功能(p:185)

C89 / C90标准(ISO / IEC 9899:1990): 4.3.2.2 toupper功能

扩展内容

tolower

将字符转换为小写(函数)

towupper(C95)

将宽字符转换为大写(函数)

| 关于toupper的C ++文档 |

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值