MFC Consol 간단한 계산. @_@;;;; 너무 쉬운거.
WindowsPrograming :
2007. 3. 28. 00:41
반응형
01: // calculator.cpp : Defines the entry point for the console application. 02: // 03: 04: #include "stdafx.h" 05: #include "calculator.h" 06: 07: #ifdef _DEBUG 08: #define new DEBUG_NEW 09: #undef THIS_FILE 10: static char THIS_FILE[] = __FILE__; 11: #endif 12: 13: ///////////////////////////////////////////////////////////////////////////// 14: // The one and only application object 15: 16: CWinApp theApp; 17: 18: using namespace std; 19: 20: int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) 21: { 22: int nRetCode = 0; 23: 24: // initialize MFC and print and error on failure 25: if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) 26: { 27: // TODO: change error code to suit your needs 28: cerr << _T("Fatal Error: MFC initialization failed") << endl; 29: nRetCode = 1; 30: } 31: else 32: { 33: CString kkk; 34: TCHAR str[255]; 35: cin >> str; 36: kkk=str; 37: int position=kkk.FindOneOf("+-/*"); 38: int a=atoi(kkk.Left(position)); 39: int b=atoi(kkk.Mid(position+1)); 40: char operatortemp = kkk.GetAt(position); 41: 42: cout<<"1:"<<a<<" "<<"2:"<<b<<endl; 43: cout<<operatortemp<<endl; 44: 45: 46: if (operatortemp == '+') 47: cout<<a+b<<endl; 48: else if (operatortemp == '-') 49: cout<<a-b<<endl; 50: else if (operatortemp == '*') 51: cout<<a*b<<endl; 52: else if (operatortemp == '/') 53: cout<<a/b<<endl; 54: 55: 56: // TODO: code your application's behavior here. 57: // CString strHello; 58: // strHello.LoadString(IDS_HELLO); 59: // cout << (LPCTSTR)strHello << endl; 60: } 61: 62: return nRetCode; 63: }
반응형
'WindowsPrograming' 카테고리의 다른 글
SetWindowEXt() SetViewportExt()는 (2) | 2007.04.04 |
---|---|
[퍼옴]MFC03 (0) | 2007.03.11 |
[퍼옴]MFC04 (0) | 2007.03.11 |