字符串大小写字母转换c 语言,C语言中对字母进行大小写转换的简单方法
C語言tolower()函數:將大寫字母轉換為小寫字母頭文件:
#include
定義函數:
int toupper(int c);
函數說明:若參數 c 為小寫字母則將該對應的大寫字母返回。
返回值:返回轉換后的大寫字母,若不須轉換則將參數c 值返回。
范例:將s 字符串內的小寫字母轉換成大寫字母。
#include
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
定義函數:
int tolower(int c);
函數說明:若參數 c 為大寫字母則將該對應的小寫字母返回。
返回值:返回轉換后的小寫字母,若不須轉換則將參數c 值返回。
范例:將s 字符串內的大寫字母轉換成小寫字母。
#include
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;!#$
總結
以上是生活随笔為你收集整理的字符串大小写字母转换c 语言,C语言中对字母进行大小写转换的简单方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: springboot中格林尼治时间转指定
- 下一篇: 白帽黑客必备的网络安全基础问答