Computer Science Canada Brand new |
Author: | rto [ Wed May 21, 2008 5:06 pm ] |
Post subject: | Brand new |
Alright. chances are most of the people that are going to be looking at my threads are going to hate me (atleast for the first little bit). i know NOTHING about c++. i started off in my introduction to computer sciences class learning turing (decent at it), worked on to java (understand it) and am now on C++. i've just downloaded the newest visual basic c++ program (vb 2008 express edition) and i have a huge problem trying to understand WHERE to put the code ![]() this is going to be long but it'll explain what i mean --> to get this i went to : File>New>Project>win32 console Application>named: test 1>next>next>windows application>finish // test1.cpp : Defines the entry point for the application. // #include "stdafx.h" #include "test1.h" #define MAX_LOADSTRING 100 // Global Variables: HINSTANCE hInst; // current instance TCHAR szTitle[MAX_LOADSTRING]; // The title bar text TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name // Forward declarations of functions included in this code module: ATOM MyRegisterClass(HINSTANCE hInstance); BOOL InitInstance(HINSTANCE, int); LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM); int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); // TODO: Place code here. MSG msg; HACCEL hAccelTable; // Initialize global strings LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInstance, IDC_TEST1, szWindowClass, MAX_LOADSTRING); MyRegisterClass(hInstance); // Perform application initialization: if (!InitInstance (hInstance, nCmdShow)) { return FALSE; } hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_TEST1)); // Main message loop: while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } return (int) msg.wParam; } // // FUNCTION: MyRegisterClass() // // PURPOSE: Registers the window class. // // COMMENTS: // // This function and its usage are only necessary if you want this code // to be compatible with Win32 systems prior to the 'RegisterClassEx' // function that was added to Windows 95. It is important to call this function // so that the application will get 'well formed' small icons associated // with it. // ATOM MyRegisterClass(HINSTANCE hInstance) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_TEST1)); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = MAKEINTRESOURCE(IDC_TEST1); wcex.lpszClassName = szWindowClass; wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL)); return RegisterClassEx(&wcex); } // // FUNCTION: InitInstance(HINSTANCE, int) // // PURPOSE: Saves instance handle and creates main window // // COMMENTS: // // In this function, we save the instance handle in a global variable and // create and display the main program window. // BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { HWND hWnd; hInst = hInstance; // Store instance handle in our global variable hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); if (!hWnd) { return FALSE; } ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); return TRUE; } // // FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_ABOUT: DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); break; case IDM_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); // TODO: Add any drawing code here... EndPaint(hWnd, &ps); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; } // Message handler for about box. INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { UNREFERENCED_PARAMETER(lParam); switch (message) { case WM_INITDIALOG: return (INT_PTR)TRUE; case WM_COMMAND: if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { EndDialog(hDlg, LOWORD(wParam)); return (INT_PTR)TRUE; } break; } return (INT_PTR)FALSE; } if you can help me out, i want to know where i would put my actual program. im really sorry, i know that im a newb and i will attempt to learn im currently reading tutorials on 2 different sites (this one being one of them) thanks alot guys ![]() |
Author: | md [ Wed May 21, 2008 5:33 pm ] |
Post subject: | RE:Brand new |
You want to make a win32 console application at first, and you want to make sure it doesn't use precompiled headers. I forget where specifically the options to do that are. A better option is to find a good syntax-highlighting text editor and install mingw. Mingw is a C++ compiler that you can run from the command line, which is really how you want to start learning. IDEs are just needlessly complicated for learning. |
Author: | Tony [ Wed May 21, 2008 5:33 pm ] | ||
Post subject: | RE:Brand new | ||
wow there. You are way off. Start by getting yourself a compiler (g++ is good) and getting familiar with how it works. Your code should start out being as simple as
|
Author: | Saad [ Wed May 21, 2008 5:36 pm ] |
Post subject: | Re: Brand new |
Woah there, hold up for a sec. Many problems with what you just did. First of all, you said Quote: i've just downloaded the newest visual basic c++ program (vb 2008 express edition) You want the C++ version not VB. VB is not the same as C++. Secondly that is not a simple C++ beginner program. You should be finding a new tutorial or get yourself a C++ book.
Furthermore you should get the g++ compiler (part of MinGW, found here) and get yourself a text editor and compile command line, instead of using Visual C++. Edit: Seems Tony and md got here before me |
Author: | michaelp [ Wed May 21, 2008 5:38 pm ] | ||
Post subject: | RE:Brand new | ||
Don't you mean:
Ph, iostream.h. |
Author: | rto [ Wed May 21, 2008 5:39 pm ] |
Post subject: | RE:Brand new |
man, like i said, completely new to this, absolutely no idea what you mean.. ![]() |
Author: | michaelp [ Wed May 21, 2008 5:45 pm ] |
Post subject: | RE:Brand new |
How exactly do you know Java and Turing, and you can't even set up a C++ environment or IDE? It's not very hard, search google for something that easy. ![]() |
Author: | rto [ Wed May 21, 2008 5:52 pm ] |
Post subject: | RE:Brand new |
thanks for the encouragement michael. im very new to programming. google searches led me here and to other sites that i didnt understand. if you guys could try putting this in lamens terms it'd be appreciated. as for the g++ compiler, im downloading it now |
Author: | rto [ Wed May 21, 2008 5:56 pm ] |
Post subject: | RE:Brand new |
ok let me try and explain a little bit better here. i type this into c++ #include <iostream.h> main() { cout << "Hello World!"; return 0; } i press debug it runs and the print window comes up . it has file, help. but absolutely nowhere does it say "hello world!" ... |
Author: | Tony [ Wed May 21, 2008 5:59 pm ] |
Post subject: | Re: Brand new |
rto @ Wed May 21, 2008 5:06 pm wrote: i started off in my introduction to computer sciences class learning turing (decent at it), worked on to java (understand it)
rto @ Wed May 21, 2008 5:06 pm wrote: im very new to programming.
As michaelp points out -- Umm... ![]() How have you even decided to pursue C++ if you know "nothing" about the language. |
Author: | rto [ Wed May 21, 2008 6:05 pm ] |
Post subject: | RE:Brand new |
when you start to learn something, chances are your not going to know anything about it . i would like to learn the basics, if somebody could give me a good tutorial than that would be excellent. the tutorial here on this website didnt help me very often. . . i've decided to pursue c++ because its going to be a big part of the course im taking next year . i would like some background knowledge on it, thanks again. |
Author: | michaelp [ Wed May 21, 2008 6:38 pm ] |
Post subject: | RE:Brand new |
Dude, you gotta download like 2 things, and search 1 or 2 on google. And you don't know anything about it. BS. If you really do know about Java and Turing, this should be cake for you. http://compsci.ca/v3/viewtopic.php?t=9420 |
Author: | rto [ Wed May 21, 2008 6:58 pm ] |
Post subject: | RE:Brand new |
i have dev c++. somebody else has already helped me out and i am very thankful ![]() |
Author: | Tony [ Wed May 21, 2008 7:08 pm ] |
Post subject: | RE:Brand new |
There isn't really a reason to delete this thread though. |
Author: | md [ Wed May 21, 2008 7:11 pm ] |
Post subject: | RE:Brand new |
The thread stays. I have spoken. |
Author: | rto [ Wed May 21, 2008 7:17 pm ] |
Post subject: | RE:Brand new |
if you feel as though this should stay thats fine, doesnt boher me any ![]() |
Author: | wtd [ Fri May 23, 2008 12:18 am ] |
Post subject: | RE:Brand new |
I should moving it to Turing Submissions just to put md in his place. |