To start programming, first you must set up your complier. I use MicroSoft Visual C++ 6.0. It is a very good, very powerful compiler. The Introductory Edition can be purchashed for about $50, so I suggest you save your money and go buy it. The only stipen with this edition of the compiler is that you cannot commercially release your programs, but at this point in your programming career, I don't think that you'll need to worry about that. I also use Borland C++ Power Builder 3.0, which is very similar to Visual Basic in terms of usage. However, for the purposes of these tutorials I will assume that you are using MS Visual C++. If you are using a different compiler and cannot get my code to work (which should not happen because I am using ANSI C++), notify me and I'll try to help you out. OK, let's do some coding!

First, go to File and then select New. From the Projects tab, select Win32 Console Application. In the Project name field, type FirstProg, and then click OK. The next screen gives you four choices, but for the purposes of this tutorial, select the radio button titled An empty project. Now finally, click Finish. A project information screen will come up giving you some stats on your project, just click OK. Now we have a working project ready. However, this project has no code, and thus does absolutely nothing. To give this project any functionality whatsoever, we must supply it with some source code. . .

To add a C++ source file to your project, you select New, then from the Files tab, select C++ Source File. In the File name field, type FirstProg. Now you're ready to type your code away (and I do recommend typing it and not just copying and pasting what I have typed, because when you actually type it, it starts to stick in your head). *Note - You could actually type your C++ source file in any pure ASCII editor, saving the document with the *.cpp extentsion.

Here's the code:

#include <iostream.h>

void main(void)
{
cout << "What's up, dude?!";
}

The next thing to do is to actually build the project and compile the source code. To do so, first select Build, then Build FirstProg.exe, or you could just press F7. This should build the project and compile the code. To see your work in action, got to Build, then Start Debug, then Go. However, an easier way would be to press F5, which will automatically recompile your source code in the event that you've changed it, whether to enhance the program or to rid it of bugs. You should not have to rebuild the program, only recompile it if you change the source. If you do need to rebuild it, you should get a message box telling you so, and then an option to rebuild, but I really wouldn't worry about that, it's not that big of a deal!

These five lines of code contain a lot of information, which I will attempt to explain in simplest terms as possible. The first line contains a preprocessor directive: #include. This preprocessor directive allows one to include a header file. It is important to note a few things here. First, throughout this code, everything is case sensitive, but as far as white space is concerned, the compiler could care less, meaning you can indent, double-space, etc. Of course, as with all rules, there are exceptions, and this code shows the two. One, in a preprocessor directive, everything must be on one line, that's it, there's no way around it. Two, with static text, everything must be on one line, unless you split the lines up with '\' character (more on that later).

The <iostream.h> header file includes the definition for the cout function. iostream = input/output stream. The "<<" is the streaming process, which I will not attempt to explain now, just keep in mind that cout uses streaming.

The main( ) function is the function in which all the action in a console mode application takes place. A program can have any number of functions, but all console mode applications (which are the type that we are making now), MUST have at least the main( ) function. The keyword void is what is known as a data type, and this data type means exactly what it means in English : nothing. In reality, we could omit the two voids in this program, and the program would execute fine, however, I decided to put them in to let you know that data types can go in those spots. The data type available is not limited to just void, as we will see in future tutorials.

The curly braces '{' and '}' are used to contain the code for the main function. All function definitions use the curly braces. Well if any of this seemed overwhelming, just reread it and take your time. The first tutorials are always the roughest because so much information is presented at once. From here on out, I will take the time to fully explain certain aspects of programming, such as functions data types, etc. I will also try to provide more examples, because examples make learning much easier as well fun (let's face it, just reading this information is boring).

The source files for this lesson can be downloaded here.