VC中數字與字串轉換方法

2021-04-20 22:29:16 字數 4006 閱讀 8523

1

crt函式

ascii

unicode

tchar

vs2005

int

atoi

_wtoi

_tstoi

_ttoi

_atoi_l

_wtoi_l

long

atol

_wtol

_tstoi

_ttoi

_atoi_l

_wtoi_l

__int64

_atoi64

_wtoi64

_tstoi64

_ttoi64

_atoi64_l

_wtoi64_l

float

_atoflt

_atoflt_l

double

atof

_wtof

_tstof

_ttof

_atof_l

_wtof_l

_atodbl

_atodbl_l

long double

_atoldbl

_atoldbl_l

2.使用

sscanf

3.windows sdk:

:strtoint

4.mfc/atl:

cstring::format

1.crt函式

ascii

unicode

tchar

vs2005

int

itoa

_itoa

_itow

_itot

long

ltoa

_ltoa

_ltow

_ltot

__int64

_i64toa

_i64tow

_i64tot

double

gcvt

_gcvt

_ecvt

_fcvt

_wtof

_tstof

_ttof

_gcvt_s

_ecvt_s

_fcvt_s

2.使用sprintf

3.<

strsafe.h>

:stringcbprintf

1.c++

流方式:

stringstream 

2.boost庫:

boost::

lexical_cast

摘自msdn:

data-conversion routines

routine

use

atof, _atof_l, _wtof, _wtof_l

convert string tofloat

atoi, _atoi_l, _wtoi, _wtoi_l

convert string toint

_atoi64, _atoi64_l, _wtoi64, _wtoi64_l

convert string to__int64

atol, _atol_l, _wtol, _wtol_l

convert string tolong

_ecvt

, _ecvt_s

convertdoubleto string of specified length

_fcvt

, _fcvt_s

convertdoubleto string with specified number of digits following decimal point

_gcvt

, _gcvt_s

convertdoublenumber to string; store string in buffer

_itoa, _i64toa, _ui64toa, _itow, _i64tow, _ui64tow

, _itoa_s, _i64toa_s, _ui64toa_s, _itow_s, _i64tow_s, _ui64tow_s

convertintor__int64to string

_ltoa, _ltow

, _ltoa_s, _ltow_s

convertlongto string

strtod, _strtod_l, wcstod, _wcstod_l

convert string todouble

strtol, wcstol, _strtol_l, _wcstol_l

convert string tolonginteger

strtoul, _strtoul_l, wcstoul, _wcstoul_l

convert string tounsigned longinteger

_ultoa, _ultow

, _ultoa_s, _ultow_s

convertunsignedlongto string

atof, _atof_l, _wtof, _wtof_l

convert wide-character string to adouble

atoi, _atoi_l, _wtoi, _wtoi_l

convert wide-character string toint

_atoi64, _atoi64_l, _wtoi64, _wtoi64_l

convert wide-character string to__int64

atol, _atol_l, _wtol, _wtol_l

convert wide-character string tolong

字串與數字轉換方法

一 字串轉數字 1.crt函式 需要的標頭檔案 ascii unicode tchar vs2005 intatoi wtoi tstoi ttoi atoi l wtoi l long atol wtol tstoi ttoi atoi l wtoi l int64 atoi64 wtoi64 t...

數字與字串轉換

題目大意 給定兩個數 i 和 j 將數字 i j 翻轉後按公升序排列輸出。include include include include includeusing namespace std struct node num 55 翻轉字串 char strrev char s int len str...

vc中字串和數字轉換的函式

vc中字串和數字轉換的函式 atoi,atol,strtod,strtol,strtoul 型別轉換 atoi,atol,strtod,strtol,strtoul實現型別轉換 atof 將字串轉換成浮點型數 相關函式 atoi,atol,strtod,strtol,strtoul 表頭檔案 inc...