C语言toupper()函数:将小写字母转换为大写字母

来源:互联网 发布:win10网络红叉 编辑:程序博客网 时间:2024/04/30 21:59
头文件:#include <ctype.h>

定义函数:int toupper(int c);

函数说明:若参数 c 为小写字母则将该对应的大写字母返回。

返回值:返回转换后的大写字母,若不须转换则将参数c 值返回。

范例:将s 字符串内的小写字母转换成大写字母。
纯文本新窗口
  1. #include <ctype.h>
  2. main(){
  3. char s[] = "aBcDeFgH12345;!#$";
  4. int i;
  5. printf("before toupper() : %s\n", s);
  6. for(i = 0; i < sizeof(s); i++)
  7. s[i] = toupper(s[i]);
  8. printf("after toupper() : %s\n", s);
  9. }

执行结果:
before toupper() : aBcDeFgH12345;!#$
after toupper() : ABCDEFGH12345;!#$
0 0
原创粉丝点击