C語言tolower()函數(shù):將大寫字母轉(zhuǎn)換為小寫字母
頭文件:
#include <ctype.h>
定義函數(shù):
int toupper(int c);
函數(shù)說明:若參數(shù) c 為小寫字母則將該對應(yīng)的大寫字母返回。
返回值:返回轉(zhuǎn)換后的大寫字母,若不須轉(zhuǎn)換則將參數(shù)c 值返回。
范例:將s 字符串內(nèi)的小寫字母轉(zhuǎn)換成大寫字母。
#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);}
執(zhí)行結(jié)果:
before toupper() : aBcDeFgH12345;!#$after toupper() : ABCDEFGH12345;!#$
C語言tolower()函數(shù):將大寫字母轉(zhuǎn)換為小寫字母
頭文件:
#include <stdlib.h>
定義函數(shù):
int tolower(int c);
函數(shù)說明:若參數(shù) c 為大寫字母則將該對應(yīng)的小寫字母返回。
返回值:返回轉(zhuǎn)換后的小寫字母,若不須轉(zhuǎn)換則將參數(shù)c 值返回。
范例:將s 字符串內(nèi)的大寫字母轉(zhuǎn)換成小寫字母。
#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);}
執(zhí)行結(jié)果:
before tolower() : aBcDeFgH12345;!#$after tolower() : abcdefgh12345;!#$
新聞熱點
疑難解答
圖片精選