大家帮忙看看要怎么解决这个问题
自己编了个计算器,可以运算乘法和求园的面积。然后编译时报错。请问要怎么办?源码:
程序代码:
#include "stdafx.h" #include <windows.h> #include <windowsx.h> #include "resource.h" #include "MainDlg.h" #include <stdio.h> #include <stdlib.h> BOOL WINAPI Main_Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) { HANDLE_MSG(hWnd, WM_INITDIALOG, Main_OnInitDialog); HANDLE_MSG(hWnd, WM_COMMAND, Main_OnCommand); HANDLE_MSG(hWnd,WM_CLOSE, Main_OnClose); } return FALSE; } BOOL Main_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam) { return TRUE; } void Main_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify) { switch(id) { case IDC_OK: TCHAR str1[256]; TCHAR str2[256]; GetDlgItemText(hwnd,IDC_EDIT1,str1,sizeof(str1)); GetDlgItemText(hwnd,IDC_EDIT2,str2,sizeof(str2)); int i1=atoi(str1); int i2=atoi(str2); int i4=i1*i2; TCHAR str4[256]; wsprintf(str4,"%i",i4); SetDlgItemText(hwnd,IDC_EDIT3,str4); break; } case IDC_OK2: TCHAR str3[256]; GetDlgItemText(hwnd,IDC_EDIT4,str3,sizeof(str3)); int i3=atoi(str3); int i5=i3*i3*3.14; wsprintf(str3,"%i",i5); SetDlgItemText(hwnd,IDC_EDIT4,str3); } void Main_OnClose(HWND hwnd) { EndDialog(hwnd, 0); }
报错信息:
C:\Program Files\Microsoft Visual Studio\MyProjects\练习\MainDlg.cpp(44) : error C2046: illegal case
C:\Program Files\Microsoft Visual Studio\MyProjects\练习\MainDlg.cpp(48) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
执行 cl.exe 时出错.
请问要怎么办?