(Hardcover - 3rd ed)
KEY BENEFIT: This fourth edition of the bestselling C reference covers two important developments: the ISO C Amendment 1 (1994), which specifies new facilities for writing portable, international programs in C; and a discussion of how to write C programs that are compatible with C++.
KEY TOPICS: Discusses the ongoing, international standardization of C++. Explores the importance of Clean C C code in the common subset of the ISO C and C++ languages. Demonstrates other ways to program in a style that is more compatible with C++.
MARKET: For programmers interested in programming in C++ and the future of C.
Every edition of this classic book has been a best-seller, and this fourth-generation update is an invaluable reference tool, with universally-noted explanations of what's standard and what has been replaced in standard C. This book also introduces the concept of "Clean C," C code written so that it can be compiled as a C++ program, and does a great job of delineating the language differences between C and C++ which often confuse the experienced C coder moving to C++. This is not the book to buy if you're a beginning programmer, but if you have plenty of C programming experience, you'll find that you need this book almost constantly for day-to-day reference. C programmers give this book acclaim for its clear explanations of the language's features, with plenty of info on the "whys" of features and examples of the misuse of common features. This updated fourth edition also includes ANSI/ISO descriptions updated with ISO C Amendment 1 and chapter discussion on C++ compatibility. This book will never leave your side.
A reference manual describing C language, run-time libraries, and a style of C programming that emphasizes portability and maintainability. Reviews language standards, C programming, and syntax notation, and covers lexical elements, declarations, types, conversions, and functions in both standard C and traditional C. This fourth edition includes ANSI/ISO descriptions updated with ISO C Amendment 1 (1994), and chapter discussions on C++ compatibility. Annotation c. Book News, Inc., Portland, OR (booknews.com)
More Reviews and RecommendationsThis best-selling, authoritative reference manual provides a complete description of the C language, the run-time libraries, and a style of C programming that emphasizes correctness, portability, and maintainability. Describing the C language more clearly and in more detail than any other book, authors Samuel P. Harbison and Guy L. Steele Jr. provide in a single manual: Standard C - the ANSI/ISO standard now supported by all new C compilers; Traditional C - common practice for twenty years, with millions of lines of code in use every day and the complete Standard and Traditional C run-time libraries. Thoroughly revised and updated, the Fourth Edition adds two important developments: the ANSI/ISO description has been updated with ISO C Amendment 1 (1994), which adds new facilities for writing portable international programs and each language chapter now discusses C++ compatibility, so you can write C programs that will be maximally portable and reusable in C and C++ environments - an important consideration for software developers.
A reference manual describing C language, run-time libraries, and a style of C programming that emphasizes portability and maintainability. Reviews language standards, C programming, and syntax notation, and covers lexical elements, declarations, types, conversions, and functions in both standard C and traditional C. This fourth edition includes ANSI/ISO descriptions updated with ISO C Amendment 1 (1994), and chapter discussions on C++ compatibility. Annotation c. Book News, Inc., Portland, OR (booknews.com)
| List of Tables | ||
| Preface to the Fourth Edition | ||
| Preface | ||
| 1 | Introduction | 3 |
| 2 | Lexical Elements | 11 |
| 3 | The C Preprocessor | 39 |
| 4 | Declarations | 65 |
| 5 | Types | 109 |
| 6 | Conversions and Representations | 161 |
| 7 | Expressions | 179 |
| 8 | Statements | 233 |
| 9 | Functions | 259 |
| 10 | Introduction to the Libraries | 283 |
| 11 | Standard Language Additions | 291 |
| 12 | Character Processing | 313 |
| 13 | String Processing | 325 |
| 14 | Memory Functions | 339 |
| 15 | Input/Output Facilities | 343 |
| 16 | Storage Allocation | 385 |
| 17 | Mathematical Functions | 389 |
| 18 | Time and Date Functions | 397 |
| 19 | Control Functions | 405 |
| 20 | Miscellaneous Functions | 415 |
| A The ASCII Character Set | 421 | |
| B Syntax of the C Language | 423 | |
| C Answers to the Exercises | 437 | |
| Index | 445 |
We expect our readers to already understand basic programming concepts, and many will have previous experience with C. In keeping with a reference format, we have presented the language in a "bottom-up" order: the lexical structure, the preprocessor, declarations, types, expressions, statements, functions, and the run0time libraries. We have included many cross-references in the text so that readers can begin at any point.
With the Third Edition of C: A Reference Manual we have fully integrated the descriptions of "traditional C" and the American National Standard X3.159-1989--"ANSI C." Many popular C compilers--including, for example, Microsoft C for the IBM PC--have been moving toward the ANSI C language for some time. Even if these compilers are not fully ANSI conforming as we write this, programmers using them are better served by books that fully cover ANSI C.
For the majority of programmers still using non-ANSI conforming implementations, we have not short-changed traditional C. We have retained the descriptions of various shortcommings and variations in pre-ANSI compilers so that programmers may avoid the less portable language areas if desired. We have been careful to note where ANSI C and traditional C differ and have given suggestions for writting programs that are portable between the two languages.
We have also taken the opportunity afforded by this edition to make more extensive changes in the text. We added studyproblems to most chapters in Part 1 so that readers may test their understanding of the language. We added various tables to highlight language features and make the text more readable. Finally, we added many examples that illustrate the use of the library facilities in Part 2. To keep the book to a reasonable length, we shortened some tedious discussions of minor technical points, and we eliminated two chapters at the end of Part 1 that contained a separate discussion of ANSI C and a large C example program. The ANSI C description is now integrated into the main text, and there are many software engineering textbooks that treat the problems of buuilding large software systems in more depth.
This book grew out of our work at Tartan Laboratories developing a family of C compilers for a wide range of computers, from micros to supermainframes. We wanted the compilers to be well documented, to provide precise and helpful error diagnostics, and to generate exceptionally efficient object code. A C program that compiles correctly with one compiler must compile correctly under al others, insofar as the hardware differences allow.
In spite of C's popularity, and the increasing number of primers and introductory texts on C, we found that there was no description of C precise enough to guide us in designing the new compilers. Similarly, no existinf description was precise enough for our programmer/customers, who would be using compilers that analized C programs more thoroughly than was the custom. In this text we have been especially sensitive to language features the affect program clarity, object code efficiency, and the portability of programs among different environments, both UNIX and non-UNIX.
C is a member of the "ALGOL family" of algebraic programming languages, and is more similar to languages such as PL/I, Pascal, and Ada, and less similar to BASIC, FORTRAN, or Lisp. A collection of papers, Comparing & Assessing Programming Languages Ada, C, and Pascal, edited by Alan R. Feuer and Narain Gehani (Prentice-Hall, 1984) discusses the similarities and differences found in C, Pascal, and Ada.
Dennis Ritchie designed the C language at Bell Laboratories in about 1972, and its ancestry dates from ALGOL 60 (1960), through Cambridge's CPL (1963), Martin Richards's BCPL (1967) and Ken Thompson's B language (1970) at Bell Labs. Although C is a general-purpose programming language, it has traditionally been used for systems programming. In particular, the popular UNIX operating system is written in C. Now widely available on both UNIX and non-UNIX systems, C is increasingly popular for applications that must be ported to different computers.
C's popularity is due to several factors. First, C provides a fairly complete set of facilities for dealing with a wide variety of applications. It has all the useful data types, including pointers, structures, and strings. There is a rich set of operators and control structures. C also has a standard run-time library that includes useful functions for input/output, storage allocation, string manipulation, and other purposes.
Second, C programs are efficient. C is a small language, and its data types and operators are closely related to the operations provided directly by most computers. Said another way, there is only a small "semantic gap" between C and the computer hardware.
Third, C programs are generally quite portable across different computing systems. Although C allows the programmer to write nonportable code, the uniformity of most C implementations makes it relatively easy to move applications to different computers and operating systems,
Finally, there is a growing number of C programs and C programmers. The UNIX operating system provides a large set of tools that improve C programming productivity and can serve as starting points for new applications. Because UNIX has been used in universities for several years, many students have C and UNIX experience.
Unfortunately, some of the very characteristics of C that account for its popularity can also pose problems for programmers. For example, C's smallness is due in large part to its lack of "confining rules," but the absence of such rules can lead to error-prone programming habits. To write well-ordered programs, the C programmer often relies on a set of stylistic conventions that are not enforced by the compiler. As another example, to allow C compilers to implement operations efficiently on a variety of computers, the precise meaning of some C operators and types is intentionally unspecified. This can create problems when moving a program to another computer.
In spite of the inelegancies, the bugs, and the confusion that often accompany C, it has withstood the test of time. It remains a language in which the experienced programmer can write quickly and well. Millions of lines of code testify to its usefulness.
Although there were many introductions to C at the time we wrote the First Edition of this book, there were no detailed descriptions of the C language.
1.1.1 Traditional C
The traditional (pre-standard) language reference is the book The C Programming Language, by Brian Kemighan and Dennis Ritchie (Prentice-Hall, 1978). In fact, it is not uncommon to see references to "K&R C." However, after the book was published the language continued to evolve in small ways; some features were added and some were dropped. Usually a consensus was reached on these features, although this consensus was not always documented. Many new implementations of C added their own variations to the language. When we use the phrase "the original definition of C" in this book, we mean specifically Kernighan and Ritchie's definition, before the post-1978 changes. When we speak of "traditional C," "classic C," or "pre-ISO C," we include the generally accepted extensions in use just prior to the ANSI standard. Kernighan and Richie produced a Second Edition of The C Programming Language in 1988 which describes ANSI C.
1.1.2 ANSI C, ISO C, Standard C
In 1982 the American National Standards Institute (ANSI) formed a technical subcommittee to propose a standard for the C language and run-time libraries. The X3J11 committee, chaired by Jim Brodie, produced a standard that was formally adopted in 1989 as American National Standard X3.159-1989, referred to as "ANSI C" or more informally as "Standard C". The standardization effort involved a large number of commercial C implementors-including ourselves-and their discussions helped to clarify existing practices as well as to map out some new features. Many parts of this book have benefited from these discussions.
Recognizing that programming is an international activity, an international standardization effort was begun as ANSI C was completed. The ISO/IEC JTCI/SC22/WGI4 (C) committee, chaired by P. J. Plauger, converted the ANSI standard to an international standard, ISOJEC 9899:1990, making only minor editorial changes. WG14 is now the official home of the common C standard ("ISO C"), with XM11 having important influence representing the U. S. programming community-although, in fact, X3J11's membership is international also.
Because there is no technical difference between ISO C and the earlier ANSI C, both may be referred to as Standard C. In this book, we refer to this common language as "ISO C."
It would be difficult to list all the changes from traditional C to ISO C, but some of the changed areas include:
1.1.3 Amendments and Corrigenda
In 1994, WG14 produced the first extensions to the ISO C standard. Amendment I includes additional facilities to support international use of C, including more library support for foreign character sets, multibyte characters and wide characters. We have incorporated the extensions of Amendment 1 into this book, and have designated them as such in the descriptions. It may be some time before all Standard C compilers incorporate the extensions in the Amendment. The additions in Amendment 1 include:
Also in 1994, WG14 produced the first correction to ISO C. Technical Corrigendum I to ISO C is not an extension, but is rather a"bug fix." It specifies 35 small changes to the standard which resolve inconsistencies or errors. Because these corrections affect more the exposition than the intent of the Standard, we have not explicitly noted them in this book. Of course, we have reviewed the text to be sure our interpretations are consistent with the Corrigendum.
Many groups have experimented with extensions to C. There is Concurrent C, with parallel processing features, and there is Numerical C, with some extensions designed for scientific programmers and others with particular concerns about complex numbers, arrays, floating-point arithmetic, etc. Objective C introduced object-oriented programming features to the language. These variations all have limited use so far, and we do not consider them in this book.
1.1.5 C++
The term "limited use" certainly does not apply to the programming language that started as an extension to C: C++, designed by Bjame Stroustrup at AT&T Bell Labs. The past few years have seen the C++ language rapidly gaining "mind share" among C programmers. Thanks to Borland, Microsoft, and the Free Software Foundation ("GNU"), most C programmers now have C++ implementations at hand. C++ includes many improvements over C that programmers need for large applications, including improved type checking and better support for data abstraction. However, C++ is also one of the more complex object-oriented programming languages, built around concepts that are still unfamiliar to many.
C++ is nearly-but not exactly-a superset of ISO C. It is possible to write C code in the common subset of the ISO C and C++ languages-called Clean C by some-so that the code can be compiled either as a C program or as a C++ program. Since C++ generally has more strict rules than ISO C, Clean C tends to be a good, portable subset to write in. The major changes you must consider when writing Clean C are:
There are several other rules and differences, but they are less likely to cause problems.
Unfortunately, we can't be as precise when speaking about C++ as we can about ISO C. The C++ language has not yet been standardized, and many current C++ implementations differ in significant ways. C++ is presently undergoing international standardization, with the first public review of the draft standard scheduled to appear in 1995. The ISO C++ committee working on the standard has introduced changes which have not yet found their way into commercial implementations. Finally, the draft of the future ISO C++ standard is still changing in significant ways. When explaining how to write Clean C, we will be talking about the version C++ as specified in the Working Draft of ISO C++ at the beginning of 1994.
In this book, we will explain how to write ISO C code so that it is acceptable to C++ compilers. We will not discuss features of C++ that are not available in ISO C. (Which, of course, includes almost everything interesting in C++.)
1.1.6 The Future of C
In accordance with ISO policies on timely reexamination of standards, WG14 will consider whether a major revision of ISO C is necessary beginning in 1995. It is too soon to tell in what direction WG14 will seek to evolve C, but it is possible that the committee will recommend adopting some of the more conservative features of C++ and perhaps some numerical extensions that have been worked on by subgroups of the standards committees.
It is unlikely that WG14 will recommend abandoning C in favor of C++. Most people believe that C and C-++ address different programming problems, and that there is merit in both languages.
1.1.7 This Text
This book describes the two major variations of C: ISO C and traditional C. It also describes two variations on ISO C: the additional features in Amendment 1, and the Clean C subset of C and C++. ISO C gives implementors some freedom in how they implement the language, and so we try to describe the common variations. We also try to indicate how to write "good" C programs-programs that are readable, portable, and maintainable....
loading...
loading...
loading...
Terms of Use, Copyright, and Privacy Policy
© 1997-2010 Barnesandnoble.com llc



