數字與字符串互換


=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-字符串轉化爲數字=-=-=-=--==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=
int atoi ( const char * str )
功 能:將字符串轉換成整型數

long int atol ( const char * str )
功 能:將字符串轉換成長整型數

   
double atof(const char *nptr);
功 能:將字符串轉換成浮點型數 
用 法:atof()會掃描參數nptr字符串,跳過前面的空格字符,直到遇上數
       字或正負符號纔開始做轉換,而再遇到非數字或字符串結束時
       ('\0')才結束轉換,並將結果返回




=-=-=-=-=- 2012/5/12 18:12:47 數字轉化爲字符串=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

char *gcvt(double number,size_t ndigits,char *buf);
功 能:將浮點型數轉換爲字符串,取四捨五入

strtod(將字符串轉換成浮點數)
double strtod(const char *nptr,char **endptr,int base);

strtol(將字符串轉換成長整型數)
long int strtol(const char *nptr,char **endptr,int base);

strtoul(將字符串轉換成無符號長整型數)
unsigned long int strtoul(const char *nptr,char **endptr,int base);


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章