tutorial C++ part0

In this lesson I will help you do decide which C++ compiler select. I will describe here Microsoft Visual C++ Express, Microsoft Visual Studio Profesional, Codeblocks and g++. Of course you can use different one if you want.

Compilers:

Microsoft Visual Studio Profesional - This is full featured Microsoft compiler for most of modern programing languages. It's not free. I don't recomend that for begin users. Microsoft Visual C++ Express - This is limited version of Microsoft Vsiaul Studio Profesional. It's free. You can download it from www.microsoft.com/express/Downloads. It's perfect for beginer programes which are going to write only for windows. Codeblocks - this is free and opensource compiler, it support lot of languages. It work on most popular OS, so it's prefect if you want to write program for few OS. For example if you want to write program for Windows, Linux and Mac. You can download it from www.codeblocks.org. If you are going to install it at windows be sure that you will download version with mingw (The true is that Codeblock by it's own it's not compiler, it's only IDE witch use compier g++). g++ - Linux command line compier. It's good if you are familiar with command line and if you want to fast compile one file program. Tipical usage look like this: g++ program/program.cpp -o program/program You can also compie program witch have more files, but for that I recommend to use makefile in that case. Instalation on most Linux dysributions look diffrerent. At Linux Debian you can install it by typing as root: apt-get install g++ It's strongly not recommended for beginer users.

Writing first program:

After you install compier you need to create new project to start working with it. Usualy something like select file -> project -> new. and few times click new. I'm sure that you can handl that and there is no need to describe that step by step. If everitying go right then you will be able to compie that code:
#include <iostream>
#include <cstdlib>
using namespace std;
 
int main()
{
  cout<<"hello world"<<endl;
  return 0;
}
So if you write that code and press "compire and run" you should see something like this:
hello world
Sometimes compier do not add pause at end of program, so program will close in blink of eye after it start. In that case you can add system("pause"); before return 0; so program will pause before end. The code will look then like this:
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
  cout<<"hello world"<<endl;
  system("pause");
  return 0;
}
If that code don't work then there is something wrong with your compiler or you put it in wrong place. In that case you can try to reinstall compiler or ask somebody for help. If everything go well then you can go to next lesson.