Chapter 1 - A Tutorial Introduction 导言
Let us begin with a quick introduction in C. Our aim is to show the essential elements of the language in real programs, but without getting bogged down in details, rules, and exceptions. At this point, we are not trying to be complete or even precise (save that the examples are meant to be correct). We want to get you as quickly as possible to the point where you can write useful programs, and to do that we have to concentrate on the basics: variables and constants, arithmetic, control flow, functions, and the rudiments of input and output. We are intentionally leaving out of this chapter features of C that are important for writing bigger programs. These include pointers, structures, most of C's rich set of operators, several control-flow statements, and the standard library.
在本书的开篇,我们首先概要地介绍C语言,主要是通过实际的程序引入C语言的基本元素,至于其中的具体细节、规则以及一些例外情况,在此暂时不多做讨论。因此,本章不准备完整、详细地讨论C语言中的一些技术(当然,这里所举的所有例子都是正确的)。我们是希望读者能尽快地写出有用的程序,为此,本章将重点介绍一些基本概念,比如变量与常量、算术运算、控制流、函数、基本输入/输出等。而对于编写较大型程序所涉及到的一些重要特性,比如指针、结构、C语言中十分丰富的运算符集合、部分控制流语句以及标准库等,本章将暂不做讨论。
This approach and its drawbacks. Most notable is that the complete story on any particular feature is not found here, and the tutorial, by being brief, may also be misleading. And because the examples do not use the full power of C, they are not as concise and elegant as they might be. We have tried to minimize these effects, but be warned. Another drawback is that later chapters will necessarily repeat some of this chapter. We hope that the repetition will help you more than it annoys.
这种讲解方式也有缺点。应该提请注意的是,在本章的内容中无法找到任何特定语言特性的完整说明,并且,由于比较简略,可能会使读者产生一些误解;再者,由于所举的例子并没有用到C语言的所有强大功能,因此,这些例子也许并不简洁、精炼。虽然我们已经尽力将这些问题的影响降到最低,但问题肯定还是存在。另一个不足之处在于,本章所讲的某些内容在后续相关章节还必须再次讲述。我们希望这种重复给读者带来的帮助效果要远远超过它的负面影响。
In any case, experienced programmers should be able to extrapolate from the material in this chapter to their own programming needs. Beginners should supplement it by writing small, similar programs of their own. Both groups can use it as a framework on which to hang the more detailed descriptions that begin in Chapter 2.
无论是利还是弊,一个经验丰富的程序员应该可以从本章介绍的内容中推知他们自己进行程序设计所需要的一些基本元素。初学者应编写一些类似的小程序作为本章内容的补充练习。无论是经验丰富的程序员还是初学者,都可以把本章作为后续各章节详细讲解的内容框架。