基本信息
- 原书名:C: A Reference Manual, Fifth Edition
- 原出版社: Prentice Hall
编辑推荐
权威全面的C语言参考,学习者必备的实用手册。
《C语言参考手册》英文版出版17年来,得到C程序员和C语言教师的广泛推崇,更被普林斯顿等著名大学用作教学参考书。本书是经过更新的第五版,包括对最新的C标准(ISO/IEC 9899:1999)的全面介绍。通过本书,你可以了解:最新的C标准C99;目前大多数程序员使用的C版本C89;传统C;与C++兼容的C;所有C版本的完全的C运行时库。
内容简介
计算机书籍
本书是关于C语言的详尽的参考手册。最新的第五版增加了对C99标准的介绍,更加符合当前C语言学习的需要。
全书共两大部分24章。第一部分讨论了C语言的所有语言特征,包括词法、预处理机制、声明、类型、表达式、语句以及函数等基本语言特性的介绍。第二部分讨论了C语言的标准库,根据它们不同的功能分别详细介绍。为帮助读者理解相关概念,本书在讨论C语言及其标准库的各方面问题时,提供了许多实例和解释。许多章里还提供了练习题,书后给出了主要练习的解答。这些练习的主要目的也为帮助读者理解C语言的基本机制及其重要细节,其中并不涉及复杂的程序设计技术与问题。
本书可以作为高等院校计算机专业C语言课程的教材和参考书,对于一般的C程序员也有重要的参考价值。
目录
1 Intnduction 3
l .l The Evolution of C 3
l .2 Which Dialect of C Should You Use? 6
l.3 An Overview of C Programming 7
l.4 Conformance 8
l.5 Syntax Notation 9
2 Lexical Elements 11
2.l Character Set l l
2.2 Comments 18
2.3 Tokens 20
2.4 Operators and Separators 20
2.5 Identifiers 2l
2.6 Keywords 23
2.7 Constants 24
2.8 C++Compatibility 38
2.9 On Character Sets, Repertoires, and Encodings 39
2.l0 Exercises 4l
前言
We expect our readers to already understand basic programming concepts, and many will be experienced C programmers. In keeping with a reference format, we present the language in a bottom-up order: lexical structure, preprocessor, declarations, types, expressions, statements, functions, and run-time libraries. We have included many crossreferences in the text so that readers can begin at any point. This Fifth Edition now includes a complete description of the latest international C standard, ISO/IEC 9899: l999 (C99). I have been careful to indicate which features of the language and libraries are new in C99 and point out how C99 differs from the previous standard, C89. This is now the only book that serves as a reference for all the major
versions of the C language: traditional C, the l989 C Standard, the l995 Amendment and Corrigenda to C89, and now the l999 C Standard. It also covers the Clean C subset of Standard C and Standard C++. Although there is much new material in C99, I have not changed the chapter and section organization of the book significantly, so readers familiar with previous editions will not have problems finding the information they need.
This book originally grew out of our work at Tartan, Inc. developing a family of C compilers for a range of computers--from micros to mainframes. We wanted the compilers to be well documented, provide precise and helpful error diagnostics, and generate exceptionally efficient object code. A C program that compiles correctly with one compiler must compile correctly under all the others insofar as the hardware differnces allow.
In l984, despite C's popularity, we found that there was no descriphon of C precise enough to guide us in designing the new compilers. Similary, no existing description was precise enough for our programmer/customers, who would be using compilers that analyzed C programs more thoroughly than was the custom at that time. In this text, we have been especially sensitive to language features that affect program clarity, object code effciency, and the portability of programs among differnt environments.
WEB SITE
We encourage readers to visit the book's Web site: CAReferenceManual. com We' ll post example code, expanded discussions, clarificahons, and links to more C resources.
In preparing this Fifth Edition, I want to especially acknowledge the critical help I received from Rex Jaeschke, former chairman of NCITS Jll; Antoine Trux of Helsinki, Finland; and Steve Adamczyk, the founder of Edison Design Group.
For assistance with previous editions, I would like to thank Jeffrey Esakov, Alan J. Filipski, Frank J. Wagner, Debra Martin, P. J. Plauger, and Steve Vinoski. Other help came from Aurelio Bignoli, Steve Clamage, Arthur Evans, Jr., Roy J. Fuller, Morris M. Kessan, George V. Reilly, Mark Lan, Mihe Hewett, Charies Fischer, Kevin Rodgers, Tom Gibb, David Lim, Stavros Macrakis, Steve Vegdahl, Christopher Vickery, Peter van der Linden, and Dave Wilson. Also Michael Angus, Mady Bauer, Larry Breed, Sue Broughton, Alex Czajkowski, Robert Firth, David Gaffney, Steve Gorman, Dennis Hamilton, Chris Hanna, Ken Hareenstien, Rex Jaeschke, Don Lindsay, Tom MacDonald, Peter Nelson, Joe Newcomer, Kevinw Nolish, David Notkin, Peter Plamondon, Roger Ray, Larry Rosler, David Spencer, and Barbara Steele.
Some of the original example programs in this book were inspired by algorithms appearing in the following works:
. Beeler, Michael, GosPer, R. William, and SchroepPel, Richard, HAKMEM AI Memo 239 (Massachusetts Institute of Technology Artificial Intelligence Laboratory, February l972);
. Bentley, Jon Louis, Writing ENcient Programs (Prentice-Hall, l982);
. Bentley, Jon Louis, "Programming Pearls" (monthly column appearing in Communications of the ACM beginning August 1983);
. Kernighan, Brian W, and Ritchie, Dennis M., The C Programming Language (Prentice-Hall, l978);
. Knuth, Donald E., The Art of Computer Programming Volumes l--3 (Addison Wesley, l968, l969, l973, l98l); and
. Sedgewick, Robert, Algorithms (Addison-Wesley, l983).
We are indebted to these authors for their good ideas.
The use of I instead of we in this Preface reflects that Guy Steele's work load has prevented him from being an active contributor to recent editions. The text still reflects his clear and rigorous analysis of the C language, but he cannot be held responsible for any new problems in this edition.
C: A Reference Manual is now over l7 years old. To all our readers: Thank you!
Sam Harbison
序言
本书可以看作是一本“带标注的C语言手册”,类似于国外常见的其他名为“Annotated XX Reference Manual,,的书籍。这种书基本上是按语言手册的方式组织内容,分门别类地介绍一种语言的各方面特征。但它们又与纯粹的手册不同,在介绍语言特征时,作者常根据情况加入一些说明性的实例,提供一些背景情况的介绍或者解释。当然,这些实例和解释的基本目的是帮助读者理解这一语言。本书是一本完整的C语言手册,内容分为两部分。第一部分讨论了C语言的所有语言特征,也包括了对预处理机制的详尽介绍。第二部分讨论了C语言的标准库。为帮助读者理解相关概念,本书在讨论C语言及其标准库的各方面问题时,提供了许多实例和解释。许多章里还提供了练习题,书后给出了主要练习的解答。这些练习的主要目的也为帮助读者理解C语言的基本机制及其重要细节,并不涉及复杂的程序设计技术与问题。
本书的另一个特点就是将 K&R C、ANSIC和 C99放在同一个框架里,互相对照着一起介绍。在讨论C语言的各种特征时,作者都介绍了C语言的不同“标准”的规定。这种组织方式有助于读者看清不同“标准”的变化和C语言的发展。书中还包含了C语言中的一些方面与C++标准的兼容性问题,可以帮助读者理解这两种关系密切的语言之间的细节差异。
如前所述,这一新版本的最重要修订就是包含了对C99标准的完整介绍,包括新标准引人的新的关键字和基本数据类型,变长数组和变长数组参数的定义和使用,数组、结构和联合成员初始化的选定描述方式等许多重要变化。在讨论标准库的第二部分里,也详细介绍了C99标准库各方面的新情况。虽然C99标准已经通过几年了,但现有书籍中完整地讨论这一标准的还很少见,本书的引进将能填补国内在这方面的空白,可供关心C99的专业工作者和教师学生参考。
作为C语言参考书,这本书是非常有价值的。我个人就觉得手边很需要这样一本参考手册,以便在编程和教学工作中随时查阅。目前市场上见到的与C语言有关的书籍中许多为教科书(也另有些定位不清的书籍),由于其写作目的和用途定位,不少书籍中并没有涵盖C语言的全部机制。许多书籍是从教学需要,或者从某种实用需要出发,介绍了C语言中一些方面的情况。这样一本参考书定会使学习C语言程序设计的人们得到很大帮助,也能给在教学、科研和系统开发中使用C语言的专业工作者们提供许多信息。
最后还想就本书的使用提一点建议:如果要将它用于自学或者课程,最好能配以适当的讨论程序设计问题的教材,这样才能更好地发挥它的作用。
裘宗燕
北京大学数学学院信息科学系
2003年2月