C Language Overview

Source: Internet
Author: User

Language is a universal programming language. It is very closely related to UNIX systems, and the UNIX system itself and most of the programs running on the system are written in C, but the C language is not limited to any one operating system or machine. Because the C language is well-suited for writing compilers and operating systems, it is called a "system programming language", but it is also suitable for writing most programs in different areas.

Many of the important concepts of C are derived from the Bcpl language. The impact of BCPL on C is indirectly derived from the B language, which is Ken. Thompson was developed on the Dec PDP-7 computer in 1970 for the first UNIX system.

Both the BCPL and the B languages have no type. In comparison, the C language provides a number of data types. Its basic types include integer and floating-point characters with multiple lengths. In addition, there are various data types derived from pointers, arrays, structs, and unions.

An expression consists of a de-operator and an operand. Any expression, including an assignment expression or a function call expression, can be a statement. The pointer provides a specific machine-independent address operator.

C Language for the implementation of well-structured programs, provides basic Process Control statements: statement Group, conditional judgment, multi-channel selection, termination test at the top of the loop, the end of the test at the bottom of the loop, jump ahead of the loop, jump to the end of the loop, absolute jump and so on.

A function can return a value of a base type, struct, union, or pointer type. Any function can be called recursively. Local variables are usually "automatic", which is re-created each time a function call is made. A function definition can be not nested, but a variable can be declared in the form of a block structure. Different functions of a C language program can appear in several separate source files that are compiled separately. A variable can be valid only inside, or it can be available outside the function but only in one source file, and it can be valid throughout the program.

The pre-processing phase of the compilation will replace the program text Riederhong, include other files, and conditionally compile.

C language is a relatively "low-level" language. This is not a derogatory remark, it simply means that the C language can handle objects that most computers can handle, such as characters, numbers, and addresses. These objects can be combined and moved by a specific machine-implemented arithmetic operator and logical operator.

The C language does not provide operations that directly handle composite objects such as strings, collections, lists, or arrays. Although the entire structure can be copied as a unit, the C language does not handle the entire array or string operation. In addition to the static definitions and stacks provided by local variables of the function, the C language does not define any memory allocation tools, nor does it provide heap and useless memory reclamation tools. Finally, the C language itself does not provide input/output functions, no read or write statements, and no built-in file access tools. All of these high-level mechanisms must be explicitly called by the function provider. Most implementations of the C language have reasonably included a standard set of these functions.

Similarly, the C language provides only simple single-threaded control flows, namely testing, looping, grouping, and subroutines, which do not provide multi-channel programming, parallel operation, synchronization, and co-routines.

While the lack of some of these features may seem like a serious deficiency ("This means that two strings must be compared by calling a function"), there are many benefits to keeping the language at a moderate scale. Because the C language is relatively small, it can be described in a relatively small space, which is also easy to learn. Programmers have reason to expect to understand, understand, and really thoroughly use the full language.

For many years, the C language was defined as the reference manual in the first edition of the C programming Language. In 1983, the National Standards Institute (ANSI) established a committee to develop a modern, comprehensive C-language definition. The final result is the ANSI standard, "ANSI C", which was completed in 1988. Most of the features of this standard have been supported by the current compiler.

This standard is based on the previous reference manual. The language itself has only made relatively few changes. One of the purposes of this standard is to ensure that the existing program is still valid, or that the compiler will issue a warning message to the new definition when the program is invalid.

The most important change for most programmers is the new syntax for function declarations and function definitions. Now, the function declaration can contain information describing the function implementation parameters, and accordingly, the defined syntax has also changed. This additional information makes it easy for the compiler to detect errors caused by a parameter mismatch. Based on our experience, this extension is very useful for languages.

The new standard also makes some minor improvements to the language: defining widely used structure assignments and enumerations as a formal part of the language, single-precision floating-point operations, explicit definition of arithmetic operator properties, especially the operation of symbolic types, and a more detailed description of preprocessing. The impact of these improvements on most programmers is relatively small.

A second important contribution to the standard is the definition of a library of functions for the C language. It describes a number of functions such as accessing the operating system (such as read-write files), formatted input/output, memory allocation, and string manipulation. The standard also defines a series of standard header files that provide a uniform method for accessing function declarations and data type declarations. This ensures that there is a compatible behavior between programs that use this library to interact with the host system. The library is largely similar to the "standard I/O library" of Unix systems. It is used in many systems. This will not feel like a change for most programmers.

Since most computers natively support the data types and control structures provided by the C language, it is possible to implement self-contained programs with only a small runtime library. Because the program can only explicitly invoke functions in the standard library, you can avoid calls to these functions if they are not needed. In addition to some of the operating system details that are hidden, most library functions can be written in C and can be ported.

Although the C language can run on most computers, it has nothing to do with the specific machine structure. A portable program can be written with a little effort, which can run on a variety of hardware without modification. The ANSI standard explicitly presents portability issues and presets a set of constants that describe the machine characteristics of the running program.

C language is not a strong type of language, but with its development, the type checking mechanism has been strengthened. Although the C language was originally defined as not in favor of swapping between pointers and integer variables, it was not forbidden, but it was not allowed. The ANSI standard requires proper declaration of variables and explicit coercion of type conversions, which have been implemented in some of the more sophisticated compilers. The new function declaration is another area where improvements have been made. The compiler warns against most data type errors and does not automatically perform type conversions between incompatible data types. However, the C language maintains its initial design idea that programmers understand what they are doing, and the only requirement is that programmers explicitly express their intentions.

As with any other language, C language has imperfect places. The precedence of some operators is incorrect, and some parts of the syntax can be further optimized. However, for a large number of programming applications, C language is a highly efficient and powerful language.

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.