Open Up Visual Studio 2008 (if you don't have it, find some help to get it and up and running)
Select Menu> File>New Project
Select 'Visual C++' as Project type and 'Win32 Console Application' Template
Type in a project Name also e.g 'Hello' and press Ok button
Don't get tempted by the 'Next' Button , Just Press 'Finish'
yow will see a code window with the following lines:-
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
This is just a template to start with, so lets start
make the code look like this by adding two lines yourself, be careful not to disturb other lines:-
#include "stdafx.h"
#include <windows.h>
int _tmain(int argc, _TCHAR* argv[])
{
MessageBoxA(NULL, "Hello", "Hello There", MB_OK);
return 0;
}
If you have done all things right you are finished coding !!!
Just double-check the above code and press F5
There You Go You will See your first Program Running, i.e Your PC Prompting Hello in a small Message Box.
What you just Did !
You instructed your development environment to supply you a template with an entry point defined. The second line you added called a built in procedure MessageBoxA that displays a message box. The first line you added included definitions available for developers (MessageBoxA is one of those definitions).
You pressed F5 instructing your machine to build the project, that is compile the code then link it to libraries and to make an executable file and then ran it in debug mode.
Do you think Visual Studio is the best IDE? leave your mark
No comments:
Post a Comment