Using Micrososft Visual C++ 5
Creating a Console App
Creating a program that runs at the MS-DOS command promt. This kind of program is known as a console application. If you are using VC++5 then the operating system you are using is either Win95 or NT4. The reason for stating this is that just because you are writing a console application it doesn't mean you are restricted to things you can do in DOS. You may think that the program is run by typing it's name at a command prompt then it will be old fashioned etc. Well the fact of the mater is unless you are doing something that requires a magic user interface then this will suffice for a lot of handy utilities ( including connecting to the internet !!!).
So we've already covered some simple 'C' code in the tutorial. Lets compile and run it using developer studio.
Step one ( after starting Visual
C++ 5 ).
Fomr the File menu select "New". You will be presented
with a property sheet with tabs along the top saying
,"Files","Projects","Workspaces",Other
Documents". Click on the projects tab.
Click on "Win32 Console Application".
Select the path where you want to create this projects and the
name of the project ( I called my project "program".
Leave everything else alone ( we want to create a new work space,
leave platforms set to Win32 ).
Press OK.
After some buzzing of the disk you will be presented with "program classes".
We now have to write some code.
There are quite a few ways of doing the next bit. We are working
in 'C' for the first thing otherwise adding a new class to the
project would create the required files.
Lets start with this. From the File menu select New and slect the
Files tab. Select "C++ source file", fill in a suitable
filename ( I called mine "main") and select OK.
You will be presented with a blank document ( it's filename is stated at the top of the window, mine is "main.cpp" ).
Type the following :
#include<stdio.h>
void main(void)
{
printf("Hello world\n");
}
We got ourselves a program. We must now "build" it. Building will preprocess, compile and link the program. From the "Build" menu select "Build projectname.exe", where projectname is the name you put in when you created the new project, mine is called "program".
In this situation I know that this program is going to work. If it doesn't then re-read this page and try again. To test the program go for broke and select "Execute projectname.exe" from the Build menu.
Instead of just Executing you program try using "Start Debug"," Go" from the build menu. This allows you to step and set breakpoints etc, use F10 to step over functions and F11 to step into. Set breakpoints using F9.
Note : Visual C++ is a registered trademark of Microsoft Corp.
Windows Application...
This page hosted
by Get
your own Free
Home Page