通过本文主要向大家介绍了c语言大小写字母转换,c语言判断字母大小写,c语言大小写字母,c语言大小写字母互换,c语言大小写字母转化等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
C语言tolower()函数:将大写字母转换为小写字母
头文件:
#include <ctype.h></div>
定义函数:
int toupper(int c);</div>
函数说明:若参数 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); }</div>
执行结果:
before toupper() : aBcDeFgH12345;!#$ after toupper() : ABCDEFGH12345;!#$</div>
C语言tolower()函数:将大写字母转换为小写字母
头文件:
#include <stdlib.h></div>
定义函数:
int tolower(int c);</div>
函数说明:若参数 c 为大写字母则将该对应的小写字母返回。
返回值:返回转换后的小写字母,若不须转换则将参数c 值返回。
范例:将s 字符串内的大写字母转换成小写字母。
#include <ctype.h> main(){ char s[] = "aBcDeFgH12345;!#$"; int i; printf("before tolower() : %s\n", s); for(i = 0; i < sizeof(s); i++) s[i] = tolower(s[i]); printf("after tolower() : %s\n", s); }</div>
执行结果:
before tolower() : aBcDeFgH12345;!#$ after tolower() : abcdefgh12345;!#$</div> </div>