Home  >  Article  >  Backend Development  >  What are the characteristics of C language and the basic steps to create it?

What are the characteristics of C language and the basic steps to create it?

coldplay.xixi
coldplay.xixiOriginal
2020-08-14 09:54:023567browse

The characteristics and basic steps of creation of C language are: 1. C language is a successful system description language and a general programming language. It has complete functions, a wide range of applications, and good portability. 2. The basic steps of creation are editing, compiling, linking and executing.

What are the characteristics of C language and the basic steps to create it?

The characteristics of C language and the basic steps for creation are:

C language characteristics:

1. C language is a successful system description language, and the UNIX operating system developed with C language is a successful example;

2. At the same time, C language is a general-purpose programming language, widely popular internationally. Many well-known computing companies in the world have successfully developed different versions of C language, and many excellent applications are also developed using C language. It is a high-level programming language with great development prospects.

3.C is an intermediate language. It combines the basic structures and statements of high-level languages ​​with the practicality of low-level languages. C language can operate on bits, bytes and addresses just like assembly language, and these three are the most basic working units of the computer. 4.C is a structural language. The distinctive feature of structural languages ​​is the separation of code and data, that is, each part of the program is independent of each other except for necessary information exchange. This structured approach can make the program hierarchy clear and easy to use, maintain and debug. C language is provided to users in the form of functions. These functions can be easily called and have a variety of loops and conditional statements to control the program flow, thus making the program completely structured.

5.C language has complete functions. Has a wide variety of data types and introduces the concept of pointers to make programs more efficient. Moreover, the calculation function and logical judgment function are also relatively powerful, which can realize the game of decision-making purpose.

6. C language has a wide range of applications. Suitable for a variety of operating systems, such as Windows, DOS, UNIX, etc.; also suitable for a variety of machine models. C language is obviously better than other interpreted high-level languages ​​for writing situations that require hardware operations. Some large-scale application software is also written in C language.

7.C language has good portability and strong data processing capabilities, so it is suitable for writing system software, three-dimensional and two-dimensional graphics and animation. It is a high-level language for numerical computation. Commonly used C language IDEs (integrated development environments) include Microsoft Visual C, Dev-C, Code::Blocks, Borland C, Watcom C, Borland C Builder, GNU DJGPP C, Lccwin32 C Compiler 3.1, High C, Turbo C, C -Free, win-tc, etc... For a beginner to learn C language, Microsoft Visual C is a better software. The interface is friendly, the functions are powerful, and debugging is also very convenient. This is a C language integrated development environment (IDE) produced by Microsoft. It mainly includes: VC 6.0, VS2005, VS2008, VS2010, etc. It is divided into enterprise version and student version. VC 6.0 is relatively easy for beginners to get started, but due to its poor support for standards, it may lead people to develop bad programming habits, so some people on the forum advocate abandoning VC 6.0. On unix/linux operating systems, when learning C language, you generally use vim/emacx to edit source files, gcc/cc to compile source files, and the make program to manage the compilation process.

Related learning recommendations: C video tutorial

There are 4 basic steps to create a C language program:

Edit, compile, link and execute

1. Edit

The editing process is to create and modify the C language program source code (written program instructions)

Some C compilers come with an editor to help manage the program. Usually provides an environment for writing, managing, developing and testing programs

Sometimes it is also called an integrated development environment (Integrated Development Environment, IDE).

Source files can also be created with regular text editors, but they must save the code as plain text without embedding additional formatting data. Do not use a word processor (such as Microsoft Word). Word processors are not suitable for writing program code because they append some formatting information when saving text. Generally speaking, if the compiler system has an editor, it will provide many functions that make it easier to write and organize programs. They often automatically format program text and highlight important language elements, making the program easier to read and easier to spot word typographical errors.

2. Compilation

The compiler can convert the source code into machine language. During the compilation process, errors will be found and reported. The input to this stage is the file produced during editing, often called the source file.

The compiler can find many invalid or unrecognized errors in the program, as well as structural errors, such as parts of the program that will never be executed. The output results of the compiler are called object codes, and the files that store them are called object files. The extensions of these files are usually .obj in the Microsoft Windows environment and usually .obj in the Linux/UNIX environment. .o. The compiler can find several different types of errors during the conversion process, most of which will prevent the creation of the object file.

If the compilation is successful, a file will be generated with the same name as the source file, but the extension is .o or .obj. If you are working under a UNIX system, the standard command to compile a C program on the command line is cc (if the compiler is GNU’s Not UNIX (GNU), the command is .gcc).

The compilation process consists of two stages. The first phase is called the preprocessing phase, during which the code is modified or added, and the second phase is the actual compilation process that generates the object code. Source files can contain preprocessing macros, which are used to add or modify C program statements.

3. Link

The linker combines various object modules generated by the compiler in the source code file, and then extracts the program from the C language Add the necessary code modules to the library and combine them into an executable file. The linker can also detect and report errors, such as missing a part of the program or referencing a library component that does not exist.

Actually, if the program is too large, it can be split into several source code files and then connected with the linker. Because it is difficult to write a large program at once, and it is impossible to use only one file. If you split it into multiple small source files, each source file provides a part of the function of the program, the development of the program will be much easier. These source files can be compiled separately, making it easier to avoid simple typing errors. Furthermore, the entire program can be developed piece by piece, and the source files that make up the program are usually integrated under the same project name, which is used to refer to the entire program.

The routines provided by the program library can perform non-C language operations, thus supporting and extending the C language. For example, the library contains routines that support operations such as input, output, calculating square roots, comparing two strings, or reading date and time information.

An error during the linking stage means that the source code must be re-edited; conversely, if the linking is successful, an executable file will be produced, but this does not necessarily mean that the program can work properly. In the Microsoft Windows environment, the extension of this executable file is .exe; in the UNIX environment, there is no extension, but it is an executable file type. Most IDEs also have a Build option, which can compile and link a program in one go.

4. Execution

The execution stage is to run the program after the above three processes are successfully completed. However, various errors can occur at this stage, including output errors, doing nothing, or even crashing the computer. Regardless of the situation, you must return to the editing stage to check and modify the source code.

At this stage, the computer will finally execute the instructions accurately. Under UNIX and Linux, the program can be executed by simply typing the compiled and linked file name. In most IDEs, there is a corresponding menu command to run or execute a compiled program. This Run command or Execute command may have its own menu, or it may be located under the Compile menu item. In a Windows environment, just run the program's .exe file, just like running other executable programs.

In any environment and any language, the four steps of editing, compiling, linking and executing the development program are the same. Figure 1-1 summarizes the various processes involved in creating a C program.

What are the characteristics of C language and the basic steps to create it?

Related recommendations: Programming Video Course

The above is the detailed content of What are the characteristics of C language and the basic steps to create it?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn