C can be found in today's operating systems, Graphical User Interfaces, and embedded systems. C is an object-oriented programming language which gives a clear structure to programs and allows code to be reused, lowering development costs. C is portable and can be used to develop applications that can be adapted to multiple platforms. C Language Introduction. Windows: There are many compilers available freely for compilation of C programs like Code Blocks and Dev-CPP. We strongly recommend Code. Intro to the C Language A C program is a collection of commands, which tell the computer to do 'something'. This collection of commands is usually called C source code, source code or just code. Commands are either 'functions' or 'keywords'.
C++ is a language that has evolved much over the years, and these tutorials explain many features added recently to the language. Therefore, in order to properly follow the tutorials, a recent compiler is needed. It shall support (even if only partially) the features introduced by the 2011 standard.
Many compiler vendors support the new features at different degrees. See the bottom of this page for some compilers that are known to support the features needed. Some of them are free!
If for some reason, you need to use some older compiler, you can access an older version of these tutorials here (no longer updated).
What is a compiler?
Computers understand only one language and that language consists of sets of instructions made of ones and zeros. This computer language is appropriately called machine language.A single instruction to a computer could look like this:
00000 | 10011110 |
A particular computer's machine language program that allows a user to input two numbers, adds the two numbers together, and displays the total could include these machine code instructions:
Dev C++ Introduction Video
00000 | 10011110 |
00001 | 11110100 |
00010 | 10011110 |
00011 | 11010100 |
00100 | 10111111 |
00101 | 00000000 |
As you can imagine, programming a computer directly in machine language using only ones and zeros is very tedious and error prone. To make programming easier, high level languages have been developed. High level programs also make it easier for programmers to inspect and understand each other's programs easier.
This is a portion of code written in C++ that accomplishes the exact same purpose:
Even if you cannot really understand the code above, you should be able to appreciate how much easier it will be to program in the C++ language as opposed to machine language.
Because a computer can only understand machine language and humans wish to write in high level languages high level languages have to be re-written (translated) into machine language at some point. This is done by special programs called compilers, interpreters, or assemblers that are built into the various programming applications.
Dev C++ Code Examples
C++ is designed to be a compiled language, meaning that it is generally translated into machine language that can be understood directly by the system, making the generated program highly efficient. For that, a set of tools are needed, known as the development toolchain, whose core are a compiler and its linker.Console programs
Console programs are programs that use text to communicate with the user and the environment, such as printing text to the screen or reading input from a keyboard.Console programs are easy to interact with, and generally have a predictable behavior that is identical across all platforms. They are also simple to implement and thus are very useful to learn the basics of a programming language: The examples in these tutorials are all console programs.
The way to compile console programs depends on the particular tool you are using.
The easiest way for beginners to compile C++ programs is by using an Integrated Development Environment (IDE). An IDE generally integrates several development tools, including a text editor and tools to compile programs directly from it.
Here you have instructions on how to compile and run console programs using different free Integrated Development Interfaces (IDEs):
IDE | Platform | Console programs |
---|---|---|
Code::blocks | Windows/Linux/MacOS | Compile console programs using Code::blocks |
Visual Studio Express | Windows | Compile console programs using VS Express 2013 |
Dev-C++ | Windows | Compile console programs using Dev-C++ |
If you happen to have a Linux or Mac environment with development features, you should be able to compile any of the examples directly from a terminal just by including C++11 flags in the command for the compiler:
Compiler | Platform | Command |
---|---|---|
GCC | Linux, among others... | g++ -std=c++0x example.cpp -o example_program |
Clang | OS X, among others... | clang++ -std=c++11 -stdlib=libc++ example.cpp -o example_program |
Index | Next: Structure of a program |
The C++ programming language consists of a vocabulary of commands that humans can understand and that can be converted into machine language fairly easily and a language structure (or grammar) that allows humans to combine these C++ commands into a program that actually does something (well, maybe does something)
The vocabulary is often known as the semantics, while the grammar is the syntax.
What’s a program?
A C++ program is a text file containing a sequence of C++ commands put together according to the laws of C++ grammar. This text file is known as the source file . A C++ source file carries the extension .CPP just as a Microsoft Word file ends in .DOC or an MS-DOS batch file ends in .BAT. The concept extension .CPP is just a convention, but it’s used almost exclusively in the PC world.
The point of programming is to write a sequence of C++ commands that can be converted into a machine language program that does whatever it is that you want done. Such machine executable programs carry the extension .EXE. The act of creating an executable program from a C++ program is called compiling (or building — there is a difference, but it’s small).
How do I program?
To write a program, you need two things: an editor to build your .CPP source file with and a program that converts your source file into a machine executable .EXE file to carry out your commands. The tool that does the conversion is known as a compiler.
Nowadays, tool developers generally combine the compiler with an editor into a single work-environment package. After entering your program, you need only click a button to create the executable file.
Dev C++ Introduction
The most popular of all C++ environments is Microsoft’s Visual C++, but the software is expensive. Fortunately, there are public domain C++ environments — the most popular of which is GNU C++. (Pronounce GNU like this: guh NEW). You can download public domain programs from the Internet. Some of these programs are not free — you are either encouraged to or required to pay some usually small fee. You do not have to pay to use GNU C++.
GNU stands for the circular definition “GNU is Not UNIX.” This joke goes way back to the early days of C++ — just accept it as is. GNU is a series of tools built by the Free Software Foundation.
GNU C++ is not some bug-ridden, limited edition C++ compiler from some fly-by-night group of developers. GNU C++ is a full-fledged C++ environment. GNU C++ supports the entire C++ language and executes all C++ programs.
Dev C++ Download For Windows 7
GNU C++ is not a Windows development package for the Windows environment. You’ll have to break open the wallet and go for a commercial package like Visual C++.