3、 將字符串轉(zhuǎn)換為其他的數(shù)據(jù)類(lèi)型
3.1 “字符串”轉(zhuǎn)換為“短整型”
字符串轉(zhuǎn)換為短整型,系統(tǒng)提供了函數(shù)atoi()實(shí)現(xiàn)這個(gè)功能,其函數(shù)原型如下:
int atoi(const char *string);
其中,參數(shù)const char *string為要轉(zhuǎn)換的字符串,返回值為轉(zhuǎn)換的結(jié)果。
3.2 “字符串”轉(zhuǎn)換為“長(zhǎng)整型”
函數(shù)原型:
long atol(const char *string)
3.3 字符串轉(zhuǎn)換為雙精度類(lèi)型
函數(shù)原型:
double atof(const char* string)
如果還想獲得更多關(guān)于《Visual C++代碼參考與技巧大全》的內(nèi)容,可點(diǎn)擊下面網(wǎng)址,
http://www.shnenglu.com/kangnixi/archive/2010/01/13/105591.html