Converting between strings and numbers in MFC _tstof _wtoi

convert string to double

Note: _wtof can be used under Unicode. But it's better to use _tstof, which is actually a macro and is interpreted differently under different character sets. In this way, both character sets can be compiled through.

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

convert string to int type

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


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326131723&siteId=291194637