How do convert a string/double type variable on WinCE 5.0 base or later

have a friend ask me how do convert a string/double variable. I think that very simple work.But WinCE is an Unicode Operation System.

You can see the following demo code

// declare test variables.

CString val = L"123457879.103241354131412";
double test = 0.0;
double test1 = 123457879.103241354131412;
TCHAR buf[256];

test = wcstod((const TCHAR*)val,NULL);                 // convert a string to double variable.
//swscanf((const TCHAR*)val,  L"%.20G",   &test);  // it’s fine, but I like ‘wcstod’ (wide char string to double)

swprintf(buf, L"%.20G", test);                                  // convert a double to string buffer.
this->GetDlgItem(IDC_EDIT1)->SetWindowText(buf);  // get an Edit1 controller for MFC Diag base applicaiton


download: a Demo code on Pocket2003 Emulator.(need VS2005/MFC)


在下方填入你的資料或按右方圖示以社群網站登入: Logo

您的留言將使用 帳號。 登出 / 變更 )

Twitter picture

您的留言將使用 Twitter 帳號。 登出 / 變更 )


您的留言將使用 Facebook 帳號。 登出 / 變更 )

Google+ photo

您的留言將使用 Google+ 帳號。 登出 / 變更 )

連結到 %s