toupper() 函数将小写字母转换为大写字母。语法:int toupper(int c)参数:c - 要转换的字符返回值:大写字母或 c 本身仅对 ascii 字符集中的字母有效locale-aware,转换可能因 locale 不同而异
C 语言中 toupper() 函数的使用
toupper() 函数用途:
toupper() 函数将小写字母转换为大写字母。
语法:
<code class="c">int toupper(int c);
参数:
- c:要转换的字符。
返回值:
- 如果 c 是小写字母,则返回大写形式;否则,返回 c 本身。
示例:
<code class="c">char c = 'a';
char upper = toupper(c);
printf("小写字母 %c 的大写字母是 %cn", c, upper);
输出:
小写字母 a 的大写字母是 A
注意事项:
- toupper() 函数对 ASCII 字符集中的字母有效。
- 对于非字母字符,toupper() 函数不会进行转换。
- toupper() 函数是 locale-aware 的,这意味着转换可能因当前 locale 设置而异。