C語言tolower()函數:將大寫字母轉換為小寫字母
頭文件:
#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;!#$
C語言tolower()函數:將大寫字母轉換為小寫字母
頭文件:
#include <stdlib.h>
定義函數:
int tolower(int c);
函數說明:若參數 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);}
執行結果:
before tolower() : aBcDeFgH12345;!#$after tolower() : abcdefgh12345;!#$
新聞熱點
疑難解答
圖片精選