1. 程式人生 > >MFC 中將字串 與數值之間的轉換 _tstof _wtoi

MFC 中將字串 與數值之間的轉換 _tstof _wtoi

將字串轉換為雙精度

注:Unicode下可使用_wtof。不過最好使用_tstof,它實際上是巨集,在不同的字符集下解釋不同。這樣兩種字符集都可以編譯通過。

CString str(_T("4.567"));
double Text = _tstof(str);

將字串轉換為 int 型別

CString str(_T("warning"));
int data = _wtoi(str);