C/C++ Development

Summary

C is a general-purpose, procedural, imperative computer programming language developed in the early 1970s by Dennis Ritchie for use on the Unix operating system. It has since spread to many other operating systems, and is now one of the most widely used programming languages. C also has had a great influence on many other popular languages, especially C++ which was originally designed as an enhancement to C. It is the most commonly used programming language for writing system software, though it is also widely used for writing applications.

1.  Quick Start

A series of steps to compile and run your first C/C++ application.

If this is the first time you compile and run C/C++ code on your computer, you need to check that either a compiler or an IDE is set up on the computer. There are many free C/C++ compilers available on the internet. Some more well known compilers include GNU GCC, Mingw32, and Borland C. An example of a IDE for C/C++ is Microsoft Visual Studio. The following example uses GNU GCC.

1.1  Installing the compiler:

- go to http://gcc.gnu.org/ , download and set up the compiler as instructed on the website - remember to set the compiler directory in the path so the compiler can be accessed everywhere. Refer to GNU for instructions.

1.2  Compiling a C program:

The simplest command in compiling a file is

gcc myprogram.c

where the output of the compiled code is “a.exe”. If you need the output of the compiled code to be a different name, then use

gcc myprogram.c –o myprogram

where the output of the compiled code is “myprogram.exe”.

1.3  Running a C program:

Either double click on the executable file in the windows explorer or type the file in prompt. In the above example, the file is either “a.exe” or “myprogram.exe”.

1.4  Compiling and running a C++ program:

Replace the command gcc with g++ in the above example (Note: C code file generally has file extension c, and C++ code file has extension cpp). Running a C++ program is same as running a C program.

2.  Resources

2.1  Sample Code

2.2  Other C\C++ tutorials

3.  Visual C++ and the Microsoft Visual Studio (2003)