strtoul (將字串轉換成無符號長整型數)

2021-07-12 03:58:16 字數 520 閱讀 8510

表頭檔案

#include

定義函式

unsigned long strtoul(const

char *nptr,char **endptr,int base);

strtoul()會將引數nptr字串根據引數base來轉換成無符號的長整型數。引數base範圍從2至36,或0。引數base代表採用的進製方式,如base值為10則採用10進製,若base值為16則採用

16進製制

數等。當base值為0時會根據情況選擇用哪種進製:如果第乙個字元是'0',就判斷第二字元如果是『x』則用16進製制,否則用8進製;第乙個字元不是『0』,則用10進製。一開始strtoul()會掃瞄引數nptr字串,跳過前面的空格字串,直到遇上數字或正負符號才開始做轉換,再遇到非數字或字串結束時('')結束轉換,並將結果返回。若引數endptr不為null,則會將遇到不合條件而終止的nptr中的字元指標由endptr返回。

返回值

返回轉換後的長整型數,否則返回erange並將錯誤**存入errno中。

將陣列轉換成字串

toarray 摘要 從 system.collections.generic.ienumerable建立乙個陣列。引數 source 要從其建立陣列的 system.collections.generic.ienumerable。型別引數 tsource source 中的元素的型別。返回結果 乙...

將資料型別轉換成字串,將字串轉換成資料型別

方法1 採用靜態方法 int a 123456789 string str string.valueof a 方法2 用包裝類轉換 float a 2.33f string str float.tostring a double a 2.33d string str double.tostring ...

YTU OJ 將整數轉換成字串

問題及 time limit 1 sec memory limit 128 mb submit 135 solved 66 submit status web board 用遞迴法將乙個整數n轉換成字串。例如,輸入483,應輸出字串 483 n的位數不確定,可以是任意位數的整數。提交函式conver...