C语言窗口问题
程序代码:
#include<windows.h> #include<stdio.h> LRESULT CALLBACK WinSunProc ( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); int WINAPI winMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASS wndcls; wndcls.cbClsExtra=0; wndcls.cbWndExtra=0; wndcls.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH); wndcls.hCursor=LoadIcon(NULL,IDC_CROSS); wndcls.hIcon=LoadIcon(NULL,IDI_ERROR); wndcls.hInstance=hInstance; wndcls.lpszMenuName=NULL; wndcls.style=CS_HREDRAW|CS_VREDRAW; RegisterClass(&wndcls); HWND hwnd; hwnd=CreateWindow ( "Visual C++ Game", "Visual C++ 游戏开发", WS_OVERLAPPEDWINDOW, 200, 200, 600, 400, NULL, NULL, hInstance, NULL); ShowWindow(hwnd,SW_SHOWNORMAL); UpdateWindow(hwnd); MSG msg; while(GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return 0; } LRESULT CALLBACK WinSunProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { char tmsg[128]={0}; int num1,num2,num3,num4,num5; num1=3+8; num2=10-7; num3=100*33; num4=155/5; num5=9%2; sprintf(tmsg,"3+8=%d 10-7=%d 100*33=%d 155/5=%d 9%%2=%d",num1,num2,num3,num4,num5); switch(uMsg) { case WM_PAINT: HDC hDC; PAINTSTRUCT ps; hDC=BeginPaint(hwnd,&ps); TextOut(hDC,150,0,tmsg,strlen(tmsg)); EndPaint(hwnd,&ps); break; case WM_CLOSE: if(IDYES==MessageBox(hwnd,"是否真的结束?","游戏开发",MB_YESNO)) { DestroyWindow(hwnd); } break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd,uMsg,wParam,lParam); } return 0; }
cfree运行显示无法定位文件
VC++显示error LNK2001: unresolved external symbol _main
Debug/SuanShuYuFuZhi.exe : fatal error LNK1120: 1 unresolved externals
有解决办法吗?