c库函数 - toupper函数

头文件:#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;!#$

 

猜你喜欢

转载自blog.csdn.net/zhaozhiyuan111/article/details/89202969