Posted: 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;
// 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;
//
// 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
//
// 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;
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
Sponsor Sponsor
md
Posted: 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.
Tony
Posted: 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
Posted: 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
michaelp
Posted: Wed May 21, 2008 5:38 pm Post subject: RE:Brand new
Posted: 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..
michaelp
Posted: 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.
rto
Posted: 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
Sponsor Sponsor
rto
Posted: 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!" ...
Tony
Posted: 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... What? That sounds like 2 years (terms?) worth of instructed CS.
How have you even decided to pursue C++ if you know "nothing" about the language.
Posted: 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.
michaelp
Posted: 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
rto
Posted: 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 i shall ask him to delete this post, i do so believe he is a moderator
Tony
Posted: Wed May 21, 2008 7:08 pm Post subject: RE:Brand new
There isn't really a reason to delete this thread though.