Share Knowledge and Skills

Saturday, 4 October 2014

c learning step by step

11:41 Posted by Unknown No comments
Learning C/C++ Step-By-Step -

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
•    For Redhat, get a gcc-c++ RPM, e.g. using Rpmfind and then install (as root) using
rpm -ivh gcc-c++-version-release.arch.rpm
•    For Fedora Core/ CentOS, install the GCC C++ compiler (as root) by using
yum install gcc-c++
•    For Mandrake, install the GCC C++ compiler (as root) by using
urpmi gcc-c++
•    For Debian, install the GCC C++ compiler (as root) by using
apt-get install g++
•    For Ubuntu, install the GCC C++ compiler by using
sudo apt-get install g++
•    If you cannot become root, get the tarball from ftp://ftp.gnu.org/ and follow the instructions in it to compile and install in your home directory.

1.2. For Mac OS X
Xcode has GCC C++ compiler bundled.

1.3. For Windows (MinGW + DevCpp-IDE)
•    Go to http://www.bloodshed.net/devcpp.html, choose the version you want (eventually scrolling down), click on the appropriate download link! For the most current version, you will be redirected to http://www.bloodshed.net/dev/devcpp.html
•    Scroll down to read the license and then to the download links. Download a version with Mingw/GCC. It's much easier than to do this assembling yourself. With a very short delay (only some days) you will always get the most current version of mingw packaged with the devcpp IDE. It's absolutely the same as with manual download of the required modules.
•    You get an executable that can be executed at user level under any WinNT version. If you want it to be setup for all users, however, you need admin rights. It will install devcpp and mingw in folders of your wish.
•    Start the IDE and experience your first project!
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;
}

0 comments:

Post a Comment