c库函数之二 - toupper函数

来源:互联网 发布:使命召唤8武器数据 编辑:程序博客网 时间:2024/06/03 23:07

头文件:#include <ctype.h>
定义函数:int toupper(int c);
函数说明:若参数 c为小写字母则将该对应的大写字母返回。
返回值:返回转换后的大写字母,若不须转换则将参数c值返回。
范例:将s字符串内的小写字母转换成大写字母。

#include <ctype.h>main(){    char s[] = "aBcDeFgH12345;!#$";    int i;    printf("before toupper() : %s\n", s);    for(i = 0; i < sizeof(s); i++)        s[i] = toupper(s[i]);    printf("after toupper() : %s\n", s);}


执行结果:
before toupper() : aBcDeFgH12345;!#$
after toupper() : ABCDEFGH12345;!#$

 

0 0
原创粉丝点击