Article Directory
Why did you suddenly write a blog about the C language series? The reason is that a younger brother of the author is about to start learning the C language in the semester of his junior year. I recall that when the author was learning the C language in college, he was struggling, and it was hard to say a word. But in the final exams, I can still get a relatively good result with more than 90 points. In order to provide some reference materials for my younger brother and return to college time, I also started to review the C language. Before formally introducing the development environment of C language, let's briefly introduce the characteristics of C language and what C language can do. I also hope that my blog notes can help more college students who are about to learn C language.
Features of c language:
C language is a general programming language, mainly used for system programming, with the following characteristics:
- Efficiency: It can also be seen from the development history of the C language that it inherits the advantages of low-level languages, produces efficient codes, and is friendly to readability and writeability. In general, the execution efficiency of the target code generated by C language is only 10% to 20% lower than that of the assembler.
- Flexibility: The grammar in the C language is eclectic, and it can be created and compounded on the basis of the original grammar, thus giving programmers more room for imagination and development.
- Rich functions: In addition to the data types in the C language, it can also express any complex data types through rich operators and custom structure types to complete the required functions.
- Strong expressiveness, the characteristics of the C language are reflected in its grammatical form similar to the language used by people, free writing form, standardized structure, and only simple control statements can easily control the program flow and complete the cumbersome program requirements.
- Good portability: Due to the good portability of the C language, C programs can be developed and operated across platforms with simple or no modifications under different operating systems.
It is precisely because of the above-mentioned advantages of the C language that it is very popular.
What can the c language do:
The C language was born in the 1970s and is an upright post-70s. It is the earliest programming language that can be written once and compiled everywhere, and each platform has a strong compiler support and a strong integrated development environment support. For example, Microsoft Visual Studio on Windows platform, XCode on Mac OS platform, etc. If you are a big coffee who has been engaged in C language development for more than 5 years, you will feel that you can control the world. C language is widely used, for example:
- MCU field
- application
- data processing
- Embedded system
- game development
1. Common development environment
There are many kinds of C language development environments, such as Tubor C and Visual C++ 6.0, the veteran level software, the Dev-C++ software launched by Bloodshed, and the currently popular Visual Studio series of software, all of which can be written C language program. However, the above software can only be installed under Windows system. If it is a Linux system, you can write C programs by downloading GCC commands. Therefore, there are many types of C language development environments. Next, let's briefly introduce these development environments.
1. Microsoft Visual Studio 2019
Microsoft Visual Studio (abbreviated as VS) is a series of development kits of Microsoft Corporation in the United States. Visual Studio is a basically complete set of development tools, and the code written in Visual Studio is applicable to all platforms supported by Microsoft. In addition to writing C language, it can also write C++, C#, ASP.NET and other languages. Therefore, Visual Studio is currently the most popular integrated development environment for Windows platform applications.
2. Microsoft Visual C++ 6.0
Microsoft Visual C++6.0 (VC, VC++, VC6 for short) is also a product of Microsoft Corporation. Visual C++ 6.0 was born in 1998. Like the Windows system, it also has three types: Standard Edition, Professional Edition and Enterprise Edition. In addition, it is also divided into English version and Chinese Version. Visual C++ 6.0 is one of Microsoft’s most successful products, but now Microsoft does not support Visual C++ 6.0, the installation package cannot be downloaded online, and Visual C++ 6.0 has compatibility issues under Windows 7, Windows 8, and Windows 10. So currently, Visual C++ 6.0 is rarely used for development, instead a series of Visual Studio launched by Microsoft Corporation.
3.
Turbo C Turbo C (TC for short) is the most common C language integrated development environment. The advantage of Turbo C is that it uses a series of drop-down menus, which integrates text editing, program compilation, linking and program operation, and has both a graphics library and a text window function library. The current Turbo C 2.0 adds error-checking function and simulation function, which facilitates program development. Although Turbo C is very powerful, it also has drawbacks. Its disadvantage is that it cannot be controlled by the mouse. Everyone is accustomed to using the mouse. Turbo C is not controlled by the mouse at all. This brings trouble to developers, so Turbo C is not liked by everyone.
4. Dev-C++
Dev-C++ is an integrated development environment suitable for beginners. It does not require installation, and it can be used directly by opening dev-c++.exe. Nevertheless, it has not been used in commercial software development. Dev-C++ was first launched by Bloodshed. For some reason, the development was stopped after 4.9.9.2 was developed. Later, Orwell continued to update and develop it. The latest version is 5.11.
5. Linux system GCC compiler
Linux is the operating system of UNIX. GCC is a free compiler for programming and development under Linux system. GCC was just a C language compiler at the beginning, which is the English abbreviation of GNU C Compiler. Now it contains compilers for many languages, such as C, C++, Ada, Java, etc., so GCC has also changed from the original GNU C Compiler to the GNU Compiler Collection. GCC has powerful functions, superior performance, and fast efficiency. It can also compile an executable super compiler on a variety of hardware platforms.
Second, install Visual Studio 2019
This section takes the installation of Visual Studio 2019 Community Edition as an example to explain the specific installation steps. The Visual Studio 2019 Community Edition is completely free, and its download address is:
https://visualstudio.microsoft.com/zh-hans/downloads/
The steps to install Visual Studio 2019 Community Edition are as follows:
- Visual Studio 2019 Community Edition installation file is exe executable file names of the form
vs_community__编译版本号.exe
, the author when writing notes, download the installation file namevs_community__492995134.1613136893.exe
file, double-click the file to start the installation. Description: When you install Visual Studio 2019 development environment, requirements must be installed on a computer.NET Framework 4.6
framework, if not installed, please go to the Microsoft website to download and install. - First, the program jumps to the Visual Studio 2019 installer interface that click the
继续
button to automatically jump to the installation options screen, as shown, the main interface will使用 C++的桌面开发
this check box, the other box, readers can be determined according to their own development if choose to install; the features to install complete selection below位置
select the path you want to install at here is not recommended to be installed on the system disk, you can choose one of the other disks to install, set up is complete, single click安装
the button. Note: When you install Visual Studio 2019 development environment, select使用 C++ 的桌面开发
this option, the position may be different from the author notes, the reader must be careful to check again.
Note: When installing the Visual Studio 2019 development environment, the computer must be connected to the Internet, otherwise the installation cannot be performed normally. - Jump to the installation progress interface as shown in the figure below, which displays the current installation progress. After waiting for the installation progress bar to complete, it will automatically enter the installation completion page. At this point you can start in the menu system, select the
Visual Studio 2019
command to start and to use development environment.
- After waiting for installation, which is 100% after the progress bar, click the
重启
button to complete the installation of Visual Studio 2019 installed. Then in the Windows开始
find Visual studio 2019 development environment, click Visual Studio 2019, if it is the first time you open Visual studio 2019, the following interface will appear, just click以后再说
the button.
- Enter the development setting interface of the Visual Studio 2019 environment, as shown in the figure, the development setting selection
Visual C++
, the color is based on the color you like, the author chose a light color, and finally clicked启动 Visual Studio 按钮
.
- Enter the Visual Studio 2019 environment startup interface, wait a few seconds, and enter the welcome interface of the Visual Studio 2019 environment, as shown in the figure below.
Three, Visual Studio 2019 development environment introduction
1. Create a project
The initial learning of C language programming is mainly completed in the Windows console application environment. The following will introduce the creation process of the console application step by step. The steps are as follows:
(1) Choose Start ⇒ All Programs ⇒ Visual Studio 2019, enter the start page of the Visual Studio 2019 development environment, and click Create New Project.
(2) In the Create New Project dialog box, select an empty project ⇒ Next option, as shown in the figure.
(3) In the New Project dialog box, select the folder type to be created, and the process of selecting the file creation operation is shown in the figure.
In the above 项目名称
file text box, enter the name you want to create a folder, enter a name for the author here Dome
. In the 位置
Save Address text box provided at the folder, by clicking on the right ...
storage location button to modify the source file.
(4) Automatically jump to the interface shown in the figure below.
(5) Select 解决方案资源管理器
the 源文件
right-click, select 添加
in 新建项
, as shown below. Or use the shortcut key Ctrl + Shift + A
to enter the add item interface.
(6) After completing step (5), it will automatically jump to the add item interface as shown in the figure.
First, select Add Item Visual C++
option, then display different files can be created in the right list box. Because to create a C file, here select c++ 文件(.cpp)
Options. Then in the bottom of the 名称
C file text box, enter the name you want to create, enter here the name of the author is Dome.c
. 位置
The text box is the storage location of the folder. The default is the location of the folder created in step (3), and there is no change. Note: Because the software only offers C++ 文件
this option, but does not affect the code written in C language, Visual Studio can be compatible with C ++ and C language code.
Note: Because you are creating a C source file, you need to change the default extension .cpp to .c in the text box. For example, to create a C source file named Dome, then Dome.c should be displayed in the text box.
(7) Click the 添加
button, thus adding a C file, as shown in FIG.
2. Menu bar
The menu bar displays all available Visual Studio 2019 commands. In addition to the file, edit, view, window, and help menus, it also provides programming-specific function menus, including project, generation, debugging, tools, and testing functions, as shown in the figure The menu bar shown.
Each menu item contains several menu commands, which are used to perform different operations. For example, the debug menu includes various commands for debugging the program, such as start debugging, start execution, and create a new breakpoint, as shown in the figure.
3. Toolbar
In order to make the operation more convenient and quicker, group the frequently used commands in the menu items into the corresponding toolbar according to the function, and then you can quickly access the frequently used menu commands through the toolbar. There are two commonly used toolbars: standard toolbar and debugging toolbar, which are introduced separately below.
(1) The toolbar shown above includes most of the commonly used command buttons, such as creating a new project, adding a new item, opening a file, saving, and saving all. The standard toolbar is shown in the figure.
(2) Click in the environment 本地 Windows 调试器
button will appear debug toolbar on the right side of the toolbar, which includes shortcut buttons for applications debugging.
4. Solution Explorer
The solution explorer (as shown in the left explorer above), which provides a view of projects and files, and provides convenient access to commands related to projects and files. The toolbar associated with this window provides common commands applicable to the highlighted items in the list. To access the Solution Explorer, select View⇒ Solution Explorer in the menu bar to open it.
5. Options window
选项
The window can be set on the environment, select the menu bar 工具
⇒ 选项
, as shown below will be able to open 选项
the window, where you can set up your development environment themes.
6. Error output window
The error output window provides immediate hints and possible solutions for errors in the code. For example, if you forget to enter a semicolon at the end of a certain code, the error shown in the figure below will be displayed in the error list. The error list is like an error prompter, it can display the error code in the program to the developer in time, and find the corresponding error code through the prompt message.
Fourth, use Visual Studio 2019 to develop C programs
The purpose of learning programming is to develop programs and make yourself a master. Then, this section uses a small program to introduce the process of developing a C program, so that you really feel the charm and value of C language program development. The C program development steps are shown in the figure.
(1) Step 1: Define the goal of the program. The goal of this program design is to output graphics and text, the theme is 学无止境,C 位出道
, and the output effect is shown in the figure.
(2) Step 2: Design the program. The process of designing this program is shown in the figure.
(3) Step 3: Write the code. The basic function of the program has been designed. The next step is to write the code according to the set function. Next, enter the following code in the Visual Studio 2019 project file:
#include <stdio.h>
int main() {
puts("------------------");
puts(" 学无止境,C 位出道");
puts("------------------");
return 0;
}
According to create a project before the step of creating a new project, the above code written Dome.c file and shortcut keys Ctrl +S
save. Entering the code is typing. If the typing content is English letters, you need to pay attention. The input code has requirements for the input method, and the input method needs to be in English half-width character format.
(4) Step 4: Compile the program
(1) Method One: On the Visual Studio 2019 menu bar 生成
, there will be a drop-down bar, the bottom has an 编译
option, as shown.
(2) Method Two: Use the shortcut keys Ctrl+F7
compiler.
If the compiler after the location of the output map output space in the 生成: 成功 1 个,失败 0 个,最新 0 个,跳过 0 个
content, says compile successfully.
(5) Step 5: Run the program
(1) selection on the Visual Studio 2019 debugger menu bar, drop-down box to select the 开始执行(不调试)
option (or use the shortcut Ctrl + F5), as shown.
(2) Run the program, and the output result is as shown in the figure.