Cprogramming 简明教程

Features of C Programming Language

Dennis Ritchie 和 Ken Thompson 于 1972 年开发了 C 编程语言,主要是为了重新实现 Unix 内核。C 由于具有低级内存访问、可移植性和跨平台等特性,仍然非常流行。C 的大多数特性已在许多其他编程语言中找到其位置。

Dennis Ritchie and Ken Thompson developed the C programming language in 1972, primarily to re-implement the Unix kernel. Because of its features such as low-level memory access, portability and cross-platform nature etc., C is still extremely popular. Most of the features of C have found their way in many other programming languages.

C 的开发已被证明是计算史上具有里程碑意义的一步。尽管当今不同的编程语言和技术在不同的应用领域占据主导地位,例如 Web 开发、移动应用程序、设备驱动程序和实用程序、嵌入式系统等,但它们的所有底层技术都受到 C 语言特性的启发。

The development of C has proven to be a landmark step in the history of computing. Even though different programming languages and technologies dominate today in different application areas such as web development, mobile apps, device drivers and utilities, embedded systems, etc., the underlying technologies of all of them are inspired by the features of C language.

任何技术的实用性取决于其重要的特性。这些特性还决定了其应用领域。在本章中,我们将概览 C 语言的一些重要特性。

The utility of any technology depends on its important features. The features also determine its area of application. In this chapter, we shall take an overview of some of the significant features of C language.

C is a Procedural and Structured Language

C 被描述为面向过程和结构化的编程语言。它之所以面向过程,是因为 C 程序是一系列指令,解释了解决给定问题的过程。这使得开发过程变得更容易。

C is described as procedure-oriented and structured programming language. It is procedural because a C program is a series of instructions that explain the procedure of solving a given problem. It makes the development process easier.

在 C 中,过程的逻辑可以使用 function calls 以结构化或模块化形式来表达。由于具有这个特性,C 通常用作向学校学生介绍编程的入门语言。

In C, the logic of a process can be expressed in a structured or modular form with the use of function calls. C is generally used as an introductory language to introduce programming to school students because of this feature.

C is a General-Purpose Language

C 语言并非针对特定的应用领域而开发。从系统编程到照片编辑软件,C 编程语言都被用于各种应用程序。

The C language hasn’t been developed with a specific area of application as a target. From system programming to photo editing software, the C programming language is used in various applications.

C 编程的一些常见应用包括 Operating Systems 、数据库、设备驱动程序等的开发。

Some of the common applications of C programming include the development of Operating Systems, databases, device drivers, etc.

C is a Fast Programming Language

C 是一种基于编译器的语言,这使得代码的编译和执行更快。源代码被翻译成特定于硬件的机器代码,这对 CPU 来说更容易执行,无需任何虚拟机,就像 Java 等某些其他语言所需要的那样。

C is a compiler-based language which makes the compilation and execution of codes faster. The source code is translated into a hardware-specific machine code, which is easier for the CPU to execute, without any virtual machine, as some of the other languages like Java need.

C 也是一种静态类型语言这一事实也使其比动态类型语言更快。作为一种基于编译器的语言,它与基于解释器的语言相比更快。

The fact that C is a statically typed language also makes it faster compared to dynamically typed languages. Being a compiler-based language, it is faster as compared to interpreter-based languages.

C is Portable

C 语言的另一个特性是其可移植性。C 程序是 machine-independent ,这意味着您可以在不同的机器上编译和运行相同的代码,而不需要或仅需要一些特定于机器的更改。

Another feature of the C language is its portability. C programs are machine-independent which means that you can compile and run the same code on various machines with none or some machine-specific changes.

C 编程提供了一个功能,根据要求在多个系统中使用同一个代码。

C programming provides the functionality of using a single code on multiple systems depending on the requirement.

C is Extensible

C 是一种可扩展语言。这意味着如果代码已经编写好,你可以使用少量修改添加新功能。从本质上讲,它允许向现有的 C 程序中添加新特性、新功能和新操作。

C is an extensible language. It means if a code is already written, you can add new features to it with a few alterations. Basically, it allows adding new features, functionalities, and operations to an existing C program.

Standard Libraries in C

大多数 C 编译器都捆绑了一个广泛的 libraries 集,其中包含若干内置函数。它包括操作系统特定实用程序、字符串处理、数学函数等。

Most of the C compilers are bundled with an extensive set of libraries with several built-in functions. It includes OS-specific utilities, string manipulation, mathematical functions, etc.

更重要的是,你还可以创建自己的用户定义函数,并将它们添加到现有的 C 库中。在这样的一个函数和运算范围中,程序员可以利用 C 语言构建各种程序和应用。

Importantly, you can also create your user-defined functions and add them to the existing C libraries. The availability of such a vast scope of functions and operations allows a programmer to build a vast array of programs and applications using the C language.

Pointers in C

C 的一个独特功能是指明计算机内部内存的能力。通过在 C 中使用指针,你可以直接与内存进行交互。

One of the unique features of C is its ability to manipulate the internal memory of the computer. With the use of pointers in C, you can directly interact with the memory.

Pointers 指向内存中的一个特定位置,并直接与其进行交互。使用 C 指针,你可以与外部硬件设备、中断等进行交互。

Pointers point to a specific location in the memory and interact directly with it. Using the C pointers, you can interact with external hardware devices, interrupts, etc.

C is a Mid-Level Programming Language

高级语言具有助记符关键字、用户定义标识符、模块性等特性。另一方面,C 编程语言提供对内存的低层次访问。这使它成为一种中级语言。

High-level languages have features such as the use of mnemonic keywords, user-defined identifiers, modularity etc. C programming language, on the other hand, provides a low-level access to the memory. This makes it a mid-level language.

作为一种中级编程语言,它为两个世界提供了最好的功能。例如,C 允许对硬件进行直接操作,而高级编程语言则无法提供这一点。

As a mid-level programming language, it provides the best of both worlds. For instance, C allows direct manipulation of hardware, which high-level programming languages do not offer.

C Has a Rich Set of Built-in Operators

C 可能是一种内置 operators 数量最多的语言,这些 operators 用来编写复杂或简化的 C 程序。除了传统的 arithmeticcomparison operators 外,当需要位级操作时,它的二进制和指针相关运算符也很重要。

C is perhaps the language with the most number of built-in operators which are used in writing complex or simplified C programs. In addition to the traditional arithmetic and comparison operators, its binary and pointer related operators are important when bit-level manipulations are required.

Recursion in C

C 语言提供了递归特性。递归意味着你可以创建一个在给定条件为真时,可自己调用多次的函数,就像循环一样。

C language provides the feature of recursion. Recursion means that you can create a function that can call itself multiple times until a given condition is true, just like the loops.

Recursion in C programming 提供了代码重用和回溯的功能。

Recursion in C programming provides the functionality of code reusability and backtracking.

User-defined Data Types in C

C 在 intfloatchar 中有三个基本 data types 。但是,C 编程可以定义任意的这三种类型的组合的数据类型,这使得它非常强大。

C has three basic data types in int, float and char. However, C programming has the provision to define a data type of any combination of these three types, which makes it very powerful.

在 C 中,你可以定义 structuresunion 类型。你还可以声明 enumerated data types

In C, you can define structures and union types. You also have the feature of declaring enumerated data types.

Preprocessor Directives in C

在 C 中,我们有 preprocessor directives ,例如 #include#define 等。它们不是语言关键词。C 中的预编译器指令执行一些重要角色,例如从库中导入函数、定义和扩展宏等。

In C, we have preprocessor directives such as #include, #define, etc. They are not the language keywords. Preprocessor directives in C carry out some of the important roles such as importing functions from a library, defining and expanding the macros, etc.

File Handling in C

C 语言不会直接操纵文件或流。处理文件 I/O 并不是 C 语言本身的一部分,而是由库及其关联的头文件处理。

C language doesn’t directly manipulate files or streams. Handling file IO is not a part of the C language itself but instead is handled by libraries and their associated header files.

File handling 通常通过流发挥作用的高层次 I/O 来实现。C 将 stdin、 stdoutstderr 识别为标准输入、输出和错误流。这些流可以被定向到磁盘文件以执行读写操作。

File handling is generally implemented through high-level I/O which works through streams. C identifies stdin, stdout and stderr as standard input, output and error streams. These streams can be directed to a disk file to perform read/write operations.

这些是 C 语言的一些重要特性,使其成为一种应用最为广泛的流行计算机语言。

These are some of the important features of C language that make it one of the widely used and popular computer languages.