HowtoForge

Learning C/C++ Step-By-Step - Page 2

02. Step-by-Step C/C++ --- IDE and Compilers for C/C++

C / C++ is a compiler based programming languages. In order to run a program you need a compiler software (i.e., GNU GCC, Tiny C, MS Visual C++, Cygwin C, Borland, Intel C etc..).  Also you need an IDE to create/edit programs (eg: Dev-C++, Code::Blocks, Eclipse, TurboC, etc..)

I am giving you a couple of examples of my favorite compiler and IDEs, You may choose the best from the vast list.

 

1. Installing GNU GCC Compiler

1.1. For Linux
1.2. For Mac OS X
1.3. For Windows (MinGW + DevCpp-IDE)
1.4. How to Create, Compile and Execute Programs
1.5. Example Programs

 

1. Installing GNU GCC Compiler

1.1.  For Linux

 

1.2. For Mac OS X

Xcode has GCC C++ compiler bundled.

 

1.3. For Windows (MinGW + DevCpp-IDE)

You will find something mostly similar to MSVC, including menu and button placement. Of course, many things are somewhat different if you were familiar with the former, but it's as simple as a handfull of clicks to let your first program run.

 

1.4. How to Create, Compile and Execute Programs

If you are using Linux, create/edit a program:

vi hello.cpp

Compilation:

g++ -Wall -g -o hello.out hello.cpp

Running a program:

 ./hello.out

 

1.5. Example Programs:

C Example Program:


\* 0001_hello.c *\
#include <stdio.h>
int main()
{
      printf("\nHello world");
      return 0;
}

 

C++ Example Program:

\* 0001_hello.cpp *\
#include <iostream>
using namespace std;
int main()
{
     cout << endl << "Hello, Happy programming";
     return 0;
}

Learning C/C++ Step-By-Step - Page 2