Code blocks installation and use of graphic tutorial (using code:: blocks to write C language program)


Code:: blocks is a free and open source C / C + + IDE. It supports GCC, MSVC + + and other compilers. It can also import DEV-C + + projects. The advantage of code:: blocks is that it is cross platform and can run on Linux, MAC and windows. It is small in size and easy to install.

Installing Code:: blocks is the same as installing ordinary software. It’s a complete fool operation, far less complicated than installing vs.

As of January 12, 2018, the latest version of code:: blocks is 17.12.

For Windows users, the code:: blocks 17.12 download address: Official Download:

For Mac users, the download address of code:: blocks 13.12: Official Download:

Or developeppaer download locally

Software name:
CodeBlocks (C / C + + integrated development environment) v17.12 Chinese installation free version (with configuration tutorial + Chinese package)
Software size:
Update time:
2018-05-02Download now

Note: within the fire wall, sometimes you may not be able to access this website. It is recommended that you go to Baidu disk to download.

Start installing Code:: blockscode:: blocks. After downloading, you will get an installation package(.exeExecutable file), double-click the file to start the installation.
1) Double click.exeProgram, directly enter the installation program, as shown in the figure below, clickNextButton:

2) Directly agree to the terms of code:: blocks, as shown in the following figure:

3) Select the build to install. Select full here, that is to install all, as shown in the following figure:

The installation program is full by default, which can be selected directlyNextnext step.

4) Select the installation path, as shown in the following figure:


You can install code:: blocks anywhere, but be careful not to include Chinese in the path.

5) Waiting for installation

After installation, clickNextButton.

6) After installation, clickfinishButton, as shown in the following figure:

After the installation, open start – > all programs, and a new folder named “CodeBlocks” is found, as shown in the figure below, which proves that the code:: blocks installation is successful (the quick open icon of CodeBlocks will also be generated on the desktop).

Previously, we have given a complete C language code, which is to output “C language Chinese network” on the display, as follows:

#include <stdio.h>
int main(){
    Put ("C language Chinese network");
    return 0;

In this section, we’ll take a look at how to run this code through CodeBlocks.

CodeBlocks fully supports the compilation of a single source file. If your program has only one source file (Beginners basically write code under a single source file), you don’t need to create a project, you can run it directly; if you have multiple source files, you need to create a project.

1) Create a new source file, open CodeBlocks, and select File > New > blank file in the upper menu bar, as shown in the following figure:


Or press directlyCtrl + Shift + NA blank source file will be created by combining keys, as shown in the following figure:


Enter the code at the beginning of this article in a blank source file:


Select File > save file from the upper menu bar, or pressCtrl + SKey combination can save the source file, as shown in the figure below.

Note: when saving, change the suffix name of the source file to. C.

2) Build executable program select build – > build in the menu bar above to complete the compilation of Hello. C.


Or press theCtrl + F9Key combination can also complete the compilation work, which is more convenient.
If there is no error in the code, CodeBlocks will see the prompt of successful compilation in the “build information” window below, as shown in the following figure:


After the compilation, open the directory where the source file is located (this tutorial is D: \ demo \), and you will see two more files: hello.o file: This is the intermediate file generated during the compilation process. The professional name of the intermediate file is the object file. hello.exe Document: it is the final executable document we need. CodeBlocks generates this file during compilation so that it can be called directly at run time.

This shows that CodeBlocks integrates the “compile + link” process in the compilation phase.

Double click hello.exe Run, did not see “C language Chinese” a few words, but will see a border flash past. This is because, after the program outputs “C language Chinese network”, the running is finished, the window will automatically close, the time is very short, so you can’t see the output result, you can only see a “border” flash by.

Modify the above code slightly to pause the program after outputting “C language Chinese net”:

int main(){
    Put ("C language Chinese network");
    return 0;

The function of the system (“pause”) statement is to pause the program. Note that the ා include < stdlib. H > statement is also added at the beginning. Otherwise, when you recompile, the build information window will prompt a warning about the system function, as shown in the following figure:


Compile and run the generated hello.exe Finally, I got my wish, and see the output result, as shown in the figure below:


Press any key on the keyboard and the program will close. In the actual development, we usually use the “build – > build and run” option in the menu:


Or press directlyF9In this way, the whole process of “compile > link > Run” can be completed with one key. The advantage of this is that the compiler will pause the program automatically, and we will not need to add the “system (” pause “) statement any more.
Delete the “system (” pause “) statement in the above code and pressF9Run the program again and the results are as follows:

3) Now, you can hello.exe Share it with your friends and tell them this is the first C program you wrote. Although the program is very simple, but you have passed the first obstacle, learned how to write code, how to generate executable code, this is a complete experience.

In the basic part of this tutorial, we teach you to write programs like this “black window”. Different from the software we usually use, they have no beautiful interface, no complex functions, and can only see some words. This is the console application, which is very similar to DOS, and early computer programs are like this.

Although the console program seems boring and boring, it is very simple, suitable for beginners, and can let you learn the basic knowledge of programming; only by consolidating the basic skills, can we develop robust GUI (graphical user interface) programs, that is, programs with interfaces.