c語言標(biāo)準(zhǔn)庫中字符轉(zhuǎn)換函數(shù)和數(shù)字轉(zhuǎn)換函數(shù)
字符轉(zhuǎn)換為數(shù)字:
#include<stdlib.h>
atoi();將字符轉(zhuǎn)換為整型 例:char ch1;int i=atoi(ch1);
atol();將字符轉(zhuǎn)化為長整型 例:char ch2;long l=atol(ch2);
atof();將字符轉(zhuǎn)化為浮點型 例:char ch3;float f=atof(ch3);
strtod(); 將字符串轉(zhuǎn)化為雙精度類型 例:string str1;double d=strtod(str1);
strtol(); 將字符串轉(zhuǎn)化為長整型 例:string str2; long int li=strtol(str2);
strtoul(); 將字符串轉(zhuǎn)化為無符長整型 例:sting str3; unsinged long int uli=str(str3);
數(shù)字轉(zhuǎn)換為字符:
itoa(); 將整型轉(zhuǎn)化為字符
例:int i; char ch1; itoa(i,ch1,radix);
radix為基數(shù):想要把ch1轉(zhuǎn)化為十進(jìn)制則為10,八進(jìn)制則為8,十六進(jìn)制則為16
ltoa(); 將長整型轉(zhuǎn)化為字符 例: long int i li; char ch2; ltoa(li,ch2,radix);
ultoa(); 將無符長整型轉(zhuǎn)化為字符 例:unsiged long int uli; char ch3; ultoa(uli,ch3,radix);
字符與字符的轉(zhuǎn)化:
#include<ctype.h>
tolower(); 將一個大寫字母轉(zhuǎn)化為小寫字母
例:char upper=C; char lower=tolower(upper);//得lower=c
toupper(); 將一一個小寫字母轉(zhuǎn)化為大寫字母
例:char lower=c; char upper=toupper(lower);//得upper=C
相關(guān)文章
C++實現(xiàn)LeetCode(48.旋轉(zhuǎn)圖像)
這篇文章主要介紹了C++實現(xiàn)LeetCode(48.旋轉(zhuǎn)圖像),本篇文章通過簡要的案例,講解了該項技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下2021-07-07
C++通過msxml調(diào)用webservice示例分享
這篇文章主要介紹了C++通過msxml調(diào)用webservice示例分享,需要的朋友可以參考下2014-03-03

