Titel: Elements of C
Autor/en: Morton H. Lewin
1. April 1986 - gebunden - 246 Seiten
Statements in C, like statements in any other programming language, consist almost entirely of expressions and special reserved words. Declarations in C, unlike declarations in other languages, also contain arbitrary expressions. Thus, studying the means by which C expressions are constructed and evaluated is especially important-particularly since the number of permissible C operators is so large. Since all of the operands in a C expression (excluding constants) must be properly declared before they are used, and since declarations themselves contain expressions, the teaching of C involves the following chicken-and-egg problem: Should one begin by considering only elementary declarations, in which case the topic of expression construction and evaluation cannot be fully treated in one place, because the operators that pertain to the more complex objects-like pointers and structures (whose declarations have not yet been introduced)--have not yet been covered, or should one postpone entirely the issue of how decla rations are written (merely assuming that all of the objects under discussion have been properly declared) in order to fully treat all types of operands and operators in one comprehensive discussion? If the student is encouraged to begin writing programs immediately, the former choice is mandatory, because even the most elementary programs must vII Preface viii contain proper declarations. Thus, most C textbooks postpone the discussion of objects like arrays, structures, and pointers (and of the operators that pertain to them) until the second half of the book is reached.
1 Introduction.- 1.1 The Significance of C.- 1.2 Prerequisite Summary.- 1.3 A Preview of C.- 1.4 This Book s Approach to C.- 2 Operators and Expressions.- 2.1 Constants.- 2.2 Identifiers.- 2.3 Operator Precedence.- 2.4 Function Calls.- 2.5 Indirect Access via Pointers.- 2.6 Array Elements as Operands.- 2.7 Some Derived Object Types.- 2.8 Structure Members as Operands.- 2.9 Relational Operators and Expressions.- 2.10 The Conditional Expression.- 2.11 Increment and Decrement Operators.- 2.12 Bitwise Logical Operations.- 2.13 Interpretation of Section 1.3 s Sample Expression.- 2.14 Arithmetic Operators.- 2.15 Assignment Operators.- 2.16 The Comma Operator.- 2.17 Data Conversions, Casts, and the sizeof Operator.- 2.18 Operator Precedence Table.- 2.19 White Space Characters.- Problems.- 3 Program Structure.- 3.1 The External Components of a C Program.- 3.2 C s Basic Data Types.- 3.3 Declarations in C.- 3.4 Function Definitions and Compound Statements.- 3.5 Storage Classes and Scope.- 3.6 Initialization.- 3.7 Structure Declarations.- 3.8 Type-names.- Problems.- 4 The C Preprocessor.- 4.1 Introduction.- 4.2 Text Replacement.- 4.3 Source File Inclusion and File Search Paths.- 4.4 Conditional Compilation.- Problems.- 5 Flow of Control.- 5.1 Introduction.- 5.2 The return Statement.- 5.3 if and if-else Statements.- 5.4 while and do while Statements.- 5.5 The for Statement.- 5.6 break, continue, and go to Statements.- 5.7 The switch Statement.- 5.8 Indentation Practices.- Problems.- 6 Advanced Topics.- 6.1 Unions.- 6.2 Fields.- 6.3 Structure Linkage.- 6.4 Pointers to Functions.- 6.5 Recursion.- 6.6 Multidimensional Arrays.- 6.7 typedef.- 6.8 Command Line Arguments.- Problems.- 7 The Standard Library.- 7.1 Introduction.- 7.2 File Access Control Blocks.- 7.3 I/O Initiation, Termination, and Redirection.- 7.4 Character and Line I/O.- 7.5 Formatted I/O.- 7.6 Binary Reads and Writes.- 7.7 Character-Type Macros and Conversions.- 7.8 Memory Allocation Functions.- 7.9 String-Handling Functions.- 7.10 Miscellaneous Library Functions.- Problems.- Solutions to Problems.- 2.- 3.- 4.- 5.- 6.- 7.- Appendix A Table of ASCII Codes.- Appendix B C Keywords and Their Uses.- Appendix C Operator Precedence Table.- Appendix D Capsule Summaries of Standard Library Functions.- Appendix E Standard Library Functions by Category.