C Programming Language

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

The authors present the complete guide to ANSI standard C language programming. Written by the developers of C, this new version helps readers keep up with the finalized ANSI standard for C while showing how to take advantage of C's rich set of operators, economy of expression, improved control flow, and data structures. The 2/E has been completely rewritten with additional examples and problem sets to clarify the implementation of difficult language constructs. For years, C programmers have let K&R guide them to building well-structured and efficient programs. Now this same help is available to those working with ANSI compilers. Includes detailed coverage of the C language plus the official C language reference manual for at-a-glance help with syntax notation, declarations, ANSI changes, scope rules, and the list goes on and on.

Author(s): Kernighan B., Ritchie D.
Edition: 2
Publisher: Prentice Hall
Year: 1988

Language: English
Commentary: обрезал большие поля
Pages: 286

Preface ix
Preface to the First Edition xi
Introduction 1

Chapter 1. A Tutorial Introduction 5
1.1 Getting Started 5
1.2 Variables and Arithmetic Expressions 8
1.3 The For Statement 13
1.4 Symbolic Constants 14
1.5 Character Input and Output IS
1.6 Arrays 22
1.7 Functions 24
1.8 Arguments — Call by Value 27
1.9 Character Arrays 28
1.10 External Variables and Scope 31

Chapter 2. Types, Operators, and Expressions 35
2.1 Variable Names 35
2.2 Data Types and Sizes 36
2.3 Constants 37
2.4 Declarations 40
2.5 Arithmetic Operators 41
2.6 Relational and Logical Operators 41
2.7 Type Conversions 42
2.8 Increment and Decrement Operators 46
2.9 Bitwise Operators 48
2.10 Assignment Operators and Expressions 50
2.11 Conditional Expressions 51
2.12 Precedence and Order of Evaluation 52

Chapter 3. Control Flow 55
3.1 Statements and Blocks 55
3.2 If-Else 55
3.3 Else-If 57
3.4 Switch 58
3.5 Loops — While and For 60
3.6 Loops — Do-while 63
3.7 Break and Continue 64
3.8 Goto and Labels 65

Chapter 4. Functions and Program Structure 67
4.1 Basics of Functions 67
4.2 Functions Returning Non-integers 71
4.3 External Variables 73
4.4 Scope Rules 80
4.5 Header Files 81
4.6 Static Variables 83
4.7 Register Variables 83
4.8 Block Structure 84
4.9 Initialization 85
4.10 Recursion 86
4.11 The C Preprocessor 88

Chapter 5. Pointers and Arrays 93
5.1 Pointers and Addresses 93
5.2 Pointers and Function Arguments 95
5.3 Pointers and Arrays 97
5.4 Address Arithmetic 100
5.5 Character Pointers and Functions 104
5.6 Pointer Arrays; Pointers to Pointers 107
5.7 Multi-dimensional Arrays 110
5.8 Initialization of Pointer Arrays 113
5.9 Pointers vs. Multi-dimensional Arrays 113
5.10 Command-line Arguments 114
5.11 Pointers to Functions 118
5.12 Complicated Declarations 122

Chapter 6. Structures 127
6.1 Basics of Structures 127
6.2 Structures and Functions 129
6.3 Arrays of Structures 132
6.4 Pointers to Structures 136
6.5 Self-referential Structures 139
6.6 Table Lookup 143
6.7 Typedef 146
6.8 Unions 147
6.9 Bit-fields 149

Chapter 7. Input and Output 151
7.1 Standard Input and Output 151
7.2 Formatted Output — Printf 153
7.3 Variable-length Argument Lists 155
7.4 Formatted Input — Scanf 157
7.5 File Access 160
7.6 Error Handling — Stderr and Exit 163
7.7 Line Input and Output 164
7.8 Miscellaneous Functions 166

Chapter 8. The UNIX System Interface 169
8.1 File Descriptors 169
8.2 Low Level I/O-Read and Write 170
8.3 Open, Creat, Close, Unlink 172
8.4 Random Access — Lseek 174
8.5 Example — An Implementation of Fopen and Getc 175
8.6 Example — Listing Directories 179
8.7 Example — A Storage Allocator 185

Appendix A. Reference Manual 191
A1 Introduction 191
A2 Lexical Conventions 191
A3 Syntax Notation 194
A4 Meaning of Identifiers 195,-
A5 Objects and Lvalues 197
A6 Conversions 197
A7 Expressions 200
A8 Declarations 210
A9 Statements 222
A10 External Declarations 225
All Scope and Linkage 227
A12 Preprocessing 228
A13 Grammar 234
Appendix B. Standard Library 241
B1 Input and Output: 241
B2 Character Class Tests: 248
B3 String Functions: 249
B4 Mathematical Functions: 250
B5 Utility Functions: 251
B6 Diagnostics: 253
B7 Variable Argument Lists: 254
B8 Non-local Jumps: 254
B9 Signals: 255
B10 Date and Time Functions: 255
Bll Implementation-defined Limits: and 257
Appendix C. Summary of Changes 259
Index 263