【发布时间】:2013-02-17 20:56:18
【问题描述】:
这让我大吃一惊,反正我找不到将 float 转换为 wchar_t 或者我找错地方了!
float cNumbers[9] = {1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0};
float x = 3.0;
float temp = 0.0;
wchar_t data[] = {0};
for(int i=0; i < sizeof(cNumbers); i++){
temp = x / cNumbers[i];
bool isInt = temp == static_cast<int>(temp);
if(isInt){
data = temp; //this is a big fail
addToList(hWnd,data);
}
}
void addToList(HWND hWnd,const wchar_t * data ){
SendMessage(GetDlgItem(hWnd,IDC_LISTBOX),LB_ADDSTRING,0,(LPARAM)data);
}
问题是我想将浮点值转换为 wchar_t 以将其发送到列表框
【问题讨论】:
-
使用 VS2012 你也可以使用
std::to_wstring(x)转换成wstring。
标签: c++ windows winapi visual-studio-2012