满意答案
zou_wei9
2013.06.13
采纳率:59% 等级:13
已帮助:4607人
//进制转换
case IDC_TWO1:
{
TCHAR str1[256];
GetDlgItemText(hwnd,IDC_NUMB,str1,sizeof(str1));
if(IsIl(str1)==FALSE)
{
MessageBox(hwnd,TEXT("输入数值错误,请重新输入"),TEXT("错误"),MB_OK|MB_ICONWARNING);
return;
}
//检验输入字符
int n1;
n1=atoi(str1);
TCHAR str2[256];
itoa(n1,str2,2);
SetDlgItemText(hwnd,IDC_TWO,str2);
}
break;
//二进制
case IDC_EIGHT1:
{
TCHAR str1[256];
GetDlgItemText(hwnd,IDC_NUMB,str1,sizeof(str1));
if(IsIl(str1)==FALSE)
{
MessageBox(hwnd,TEXT("输入数值错误,请重新输入"),TEXT("错误"),MB_OK|MB_ICONWARNING);
return;
}
//检验输入字符
int n1;
n1=atoi(str1);
TCHAR str2[256];
itoa(n1,str2,8);
SetDlgItemText(hwnd,IDC_EIGHT,str2);
}
break;
//八进制 case IDC_TEN1:
{
TCHAR str1[256];
GetDlgItemText(hwnd,IDC_NUMB,str1,sizeof(str1));
if(IsIl(str1)==FALSE)
{
MessageBox(hwnd,TEXT("输入数值错误,请重新输入"),TEXT("错误"),MB_OK|MB_ICONWARNING);
return;
}
//检验输入字符
int n1;
n1=atoi(str1);
TCHAR str2[256];
itoa(n1,str2,10);
SetDlgItemText(hwnd,IDC_TEN,str2);
}
break;
//十进制
default:
break;//通过itoa函数进行转换下面是我做出的效果图:
10分享举报