C Language Primer (1)--c language overview

Source: Internet
Author: User


1. Program and programming language

We use computers without programs. The program tells the computer how to run it. program is a sequence of instructions that accurately describes how to calculate. The calculation here can be a mathematical operation, for example, by some mathematical formula to solve, but also can be symbolic operations. For example, we use world to edit a document or retrieve information from a search engine.

A computer is essentially an arithmetic machine composed of digital electronic circuits, all of which can be represented and processed by numbers only. By converting a variety of data to a digital representation, the computer can process a variety of information. For example, music, pictures, movies, etc.

A program consists of a series of instructions that command the computer to do some sort of operation. Typically, the following six classes are included:

Input class directives : Used to obtain data from a keyboard, file, or other device.

Output class directives: used to display data to the screen. or deposit a file. or send it to another device, such as a printer.

basic Operation class directives: used to run the most important mathematical operations (subtraction) and data access. In fact, input and output are also data access.

Test and branching directives: used to infer whether a condition is true, and then to run different maybe directives based on different results.

Cyclic class directives : Used to run a series of operations repeatedly.

For a program, there are several types of instructions above that are sufficient. Whatever program you've used, no matter how complex it is, is made up of these kinds of instructions.

The code can be said to be such a process: the complex task of decomposition into sub-task, the task to break down into a more simple task, layer decomposition, until the last simple to be able to use the above instructions to complete.

In a different programming language. directives have different forms. Usually the word "instruction" refers to instructions in low-level languages such as machine language or assembly language, and is often referred to as statements or expressions in high-level languages such as C, C + +, Java, and Python.

Computer language is usually divided into low-level and high-level languages. The instruction that a computer can directly understand is machine language, which consists of a sequence of instructions consisting of "0" and "1". Because machine language is difficult for people to remember, difficult to understand. It has been improved by the use of concise English letters, symbolic strings instead of a binary string of a particular instruction, and assembly language appeared. Machine language and assembly languages are very dependent on machine hardware. The two languages are of a lower language.

Because the low-level language is more verbose, complex, easy error. and need to have a lot of other computer professional knowledge. So there's a high-level language. Advanced does not only synthesize a number of related machine instructions into a single instruction, but also removes details related to the detailed operation that are not relevant to the finished work, such as the use of stacks, registers, etc., which greatly simplifies the instructions in the program.

The high-level language used frequently is very rich. such as: C, C + +, JAVA, C #, Python and so on.

2, C language Simple introduction

C language is a computer programming language, which has the characteristics of high-level language. Also has the characteristics of assembly language. It was launched in 1972 by Dennis M. Ritchie of the American Bell Laboratory. After the C language has been transplanted to large, medium, small and microcomputer, it can be used as a working system design language, writing system applications. It can also be used as an application design language to write applications that do not rely on computer hardware. It has a wide range of applications. With very strong data processing ability, suitable for writing system software, three-dimensional, two-dimensional graphics and animation, detailed applications such as single-chip microcomputer and embedded system development.

C language is a general-purpose, process-type programming language. Widely used in system and application software development. With the characteristics of high efficiency, flexibility, rich function, strong expression and high portability, it is favored in the program ape.

The latest 25 is the most widely used programming language.

The C language is significantly better than other high-level languages in terms of operating system and system usage, and where hardware needs to be manipulated.

The design of C language affects many later programming languages. such as C + +, objective-c, Java, C # and so on.

The 1980s. In order to avoid the differences in C language grammar used by each development manufacturer, the United States National Standards Bureau has set up a complete set of international standard grammar for C language, called ANSI C. As a standard for C language. The 1980s to date the relevant program development tools, generally support the ANSI C-compliant syntax. C language from birth to now has three standards: ANSI c/c89 Standard, C99 Standard and C11 standard.

C language has many advantages. The main points are as follows:

1, simple and compact, flexible and convenient

There are only 32 keyword,9 control statements in C language altogether. The program is written in a free form, distinguishing between uppercase and lowercase.

Combine the basic structures and statements of high-level languages with the usefulness of low-level languages. The C language can operate on bits, bytes, and addresses like assembly language, which are the main unit of work for computers.

2. Rich operator

The C-language operators include a very wide range. There are 34 types of operators in common. The C language handles parentheses, assignments, coercion type conversions, and so on as operators.

So the operation type of C language is very rich, the expression type is diversified.

The flexibility to use a variety of operators can actually be difficult to implement in other high-level languages today.

3. Rich data types

The data types of C language are: integer, real, character, array type, pointer type, struct type, common body type, etc. Can be used to implement a variety of complex data structure operations. The concept of pointers is introduced to make the program more efficient.

4. Flexible and useful expression method

C language provides a variety of operators and expression values, the expression of the problem can be obtained through a variety of ways. Its program design is more active and flexible. It is not very restrictive in syntax. The programming freedom is large, such as the integer and character data and logical data can be generalized.

5, agree to direct access to the physical address. Working with the hardware

Because the C language agrees to direct access to the physical address, it is able to operate directly on the hardware. Therefore, it has the function of high-level language, but also has many functions of low-level language, can be like assembly language bit (bit), byte and address to operate, and these three are the computer's most important unit of work, can be used to write system software. [20]

6. High quality of generated target code. High efficiency of program operation

C language Descriptive narrative problem is faster than assembly language. The workload is small, readable, easy to debug, modify and transplant, and the code quality and assembly language equivalent.

C language is generally less efficient 10%~20% than the object code generated by the assembler. [19]

7, good portability

C language on different machines C compiler program, 86% of the code is public, so C language compiler easy to transplant. Programs written in C in an environment can be ported to a completely different environment without modification or modification. [19]

8. Strong expressive Force

The C language has rich data structures and operators.

Includes a variety of data structures, such as Integer, array type, pointer type, union type, and so on. Used to implement a variety of data structure operations.

The C language can directly access the physical address of the hardware and can perform bit operation. There are many advantages of both high-level and low-level languages.

It can be used to write system software. can also be used to develop application software, has become a general programming language.

In addition, the C language has powerful graphics features and supports a variety of displays and drives.

and the computation function, logic inference function is powerful.

3, C language how to generate programs

The C language code we have written is not straightforward and requires a series of steps to convert it into a program that can run on hardware (running code).

The most important step is to compile and link.

Compiling is the process of translating the text form source into the target document in the form of machine language. The compilation process requires the use of a compiler. A link is the process of organizing the target file, the startup code of the operating system, and the library file used to create a running code. The linking process requires the use of a linker.

The process of compiling and linking is as follows:

4, C language compiler

C language compiler a wide variety, more often used in the following several.

1, GNU/GCC

This is a compiler developed by the GNU organization. Originally used for UNIX systems.

Now GCC is a must-have compiler for the unix/linux system.

Official website: http://gcc.gnu.org/

2, VC compiler

In strict sense, VC does not count as a compiler. It should be the IDE with the compiler integrated, which is the first choice for Windows system development. The current latest version is VC2013.

Official website: http://www.visualstudio.com/

3. Intel C + + Compiler

Intel C++compiler is an Intel C + + compiler developed by the United States of America for Linux, Microsoft Windows, and the Mac OS X operating system. The latest release of the compiler is Intel C + + Compiler version 2013

Official website: http://software.intel.com/en-us/articles/intel-compilers/

4. MINGW32/CYGWIN/DJGPP Compiler

These three are all branches of GNU/GCC.

The C-Language primer series mainly uses the VC2013 environment for commentary and relates to the GCC compilation environment.

C Language Primer (1)--c language overview

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.