0% found this document useful (0 votes)
7 views4 pages

A Book On C - 4th - Ed05

This document is a book on C programming by Al Kelley and Ira Pohl, detailing various aspects of the C language including its standards, data types, and control structures. It includes a disclaimer about trademarks, liability, and offers information for bulk purchases. The book is published by Addison-Wesley and contains extensive content organized into chapters covering fundamental concepts and advanced topics in C programming.

Uploaded by

Negrea Cristian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views4 pages

A Book On C - 4th - Ed05

This document is a book on C programming by Al Kelley and Ira Pohl, detailing various aspects of the C language including its standards, data types, and control structures. It includes a disclaimer about trademarks, liability, and offers information for bulk purchases. The book is published by Addison-Wesley and contains extensive content organized into chapters covering fundamental concepts and advanced topics in C programming.

Uploaded by

Negrea Cristian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Many of the designations used by manufacturers and sellers to distinguish their products are claimed as

trademarks, Where those designatious appear in this book, and we were aware of a trademark claim, the
designations have been printed in initial capital letters or in all capitals.

The author and publisher have taken care in the preparation of this book, but make no expressed or
implied warranty of any kind and assume no responsibility for errors or omissions. No liability is
assumed for incidental or consequential damages in connection with or arising out of the use of the
information or programs contained herein.

The publisher offers discounts on this book when ordered in quantity for special sales. For more informa-
tion, please contact: For our Parents
Pearson Education Corporate Sales Division
201 W. 103rd Street
Indianapolis, IN 46290
(800) 428-5331
corpsales@pearsoned.com

Visit AW on the Web: www.awl.com/cseng/

Librmy of Congress Cataloging-in-Publication Data


Kelley,Al
A book on C: programming in C I Al Kelley, Ira Pohl. -4th ed.
p. cm.
Includes bibliographical references and index
ISBN 0-201-18399-4
1. C (Computer program language) 1. Poh!, Ira, II. Title.
QA76.73.C15K44 1997
005.13'3--dc21 97-44551
CIP
Copyright © 1998 by Addison-Wesley

All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or
transmitted, in any form, or by any means, electronic, mechanical, photocopying, recording, or other-
wise, without the prior consent of the publisher. Printed in the United States of America. Published
simultaneously in Canada.

Text printed on recycled and acid-free paper.


ISBN 0201183994
9 1011121314 MA 04030201
9th Printing November 2001
Contents

Preface xvii

Chapter 0
Starting from Zero 1
0.1 Why C? 2
0.2 ANSI C Standard 3
0.3 From C to C++ 3
0.4 From C and C++ to Java 4

Chapter 1
An Overview of C 5
1.1 Programming and Preparation 5
1.2 Program Output 6
1.3 Variables, Expressions, and Assignment 10
1.4 The Use of #defi ne and #i ncl ude 13
1.5 The Use of pri ntfO and scanfO 18
1.6 Flow of Control 21
1.7 Functions 29
Call-by-Value 35
1.8 Arrays, Strings, and Pointers 36
Arrays 37
Strings 39
Pointers 42
1.9 Files 47
viii ., Contents
., Contents ix

1.10 Operating System Considerations 53


Writing and Running a C Program 3.11 Conversions and Casts 131
53 The Integral Promotions 131
Interrupting a Program 56
Typing an End-of-file Signal The Usual Arithmetic Conversions 131
56 Casts 133
Redirection of the Input and the Output 56
Summary 3.12 Hexadecimal and Octal Constants 134
Exercises
58 e13 Summary 137
60 Exercises 138
Chapter 2
Chapter 4
lexical Elements, Operators, and the C System 69
2.1 Characters and lexical Elements Flow of Control 147
2.2 Syntax Rules
70 4.1 Relational, Equality, and logical Operators 147
2.3 Comments
73 4.2 Relational Operators and Expressions 149
2.4 Keywords
75 4.3 Equality Operators and Expressions 152
2.5 Identifiers
77 4.4 logical Operators and Expressions 154
2.6 Constants
78 Short-circuit Evaluation 157
79 4.5 The Compound Statement 157
2.7 String Constants
80 4.6 The Expression and Empty Statement 158
2.8 Operators and Punctuators
81
2.9 Precedence and Associativity of Operators 4.7 The i f and the i f-el se Statements 159
83 4.8 The whi 1e Statement 163
2.10 Increment and Decrement Operators 85
2.11 Assignment Operators 4.9 The for Statement 167
87 4.10 An Example: Boolean Variables 169
2.12 An Example: Computing Powers of 2 89
2.13 The C System 4.11 The Comma Operator 171
91 4.12 The do Statement 172
The Preprocessor
91 4.13 An Example: Fibonacci Numbers 174
The Standard library 92
Summary 4.14 The goto Statement 178
Exercises
96 4.15 The break and conti nue Statements 179
98 4.16 The swi tch Statement 181
Chapter 3 4.17 The Conditional Operator 182
Summary 184
The Fundamental Data Types 107 Exercises 185
3.1 Declarations, Expressions, and Assignment 107
3.2 The Fundamental Data Types
110
3.3 Characters and the Data Type char
Chapter 5
111 Functions 197
3.4 The Data Type i nt
116 5.1 Function Definition 197
3.5 The Integral Types short, long, and unsi gned 11 7
3.6 The Floating Types 5.2 The return Statement 200
119 5.3 Function Prototypes 201
3.7 The Use of typedef
122 Function Prototypes in C++ 202
3.8 The si zeof Operator
122
3.9 The Use of getcharO and putcharO 5.4 An Example: Creating a Table of Powers 203
124 5.5 Function Declarations from the Compiler's Viewpoint 204
3.10 Mathematical Functions 127
The Use of abs 0 and fabs 0 limitations 205
130 5.6 An Alternate Style for Function Definition Order 206
UNIX and the Mathematics library 130 5.7 Function Invocation and Call-by-Value 207
x " Contents " Contents xi

5.8 Developing a Large Program 209 6.14 Arguments to ma; nO 290


What Constitutes a Large Program? 212 6.15 Ragged Arrays 292
5.9 Using Assertions 212 6.16 Functions as Arguments 293
5.10 Scope Rules 213 Functions as Formal Parameters in Function Prototypes 296
Parallel and Nested Blocks 215 6.17 An Example: Using Bisection to Find the Root of a Function 296
Using a Block for Debugging 216 The Kepler Equation 300
5.11 Storage Classes 216 6.18 Arrays of Pointers to Function 302
The Storage Class auto 216 6.19 The Type Qualifiers const and vol at; 1 e 307
The Storage Class extern 217 Summary 309
The Storage Class reg; ster 219 Exercises 311
The Storage Class stat; c 220
5.12 Static External Variables 221
5.13 Default Initialization
Chapter 7
223 Bitwise Operators and Enumeration Types 331
5.14 Recursion 223
Efficiency Considerations 7.1 Bitwise Operators and Expressions 331
227
5.15 An Example: The Towers of Hanoi Bitwise Complement 333
228
Summary Two's Complement 333
233
Exercises Bitwise Binary Logical Operators 334
235 Left and Right Shift Operators 335
Chapter 6 7.2 Masks 337
7.3 Software Tools: Printing an ; nt Bitwise 338
Arrays, Pointers, and Strings 245 7.4 Packing and Unpacking 341
6.1 One-dimensional Arrays 245 Multibyte Character Constants 344
Initialization 246 7.5 Enumeration Types 345
Subscripting 247 7.6 An Example: The Game of Paper, Rock, Scissors 348
6.2 Pointers 248
6.3
Summary 356
Call-by-Reference 252 Exercises 357
6.4 The Relationship Between Arrays and Pointers 253
6.5 Pointer Arithmetic and Element Size 255
6.6 Chapter 8
Arrays as Function Arguments 256
6.7 An Example: Bubble Sort The Preprocessor 365
257
6.8 Dynamic Memory Allocation With call oc 0 and mall oc 0 8.1 The Use of #i ncl ude 365
259 8.2
Offsetting the Pointer The Use of #def; ne 366
262
6.9 An Example: Merge and Merge Sort Syntactic Sugar 367
263
6.10 Strings 8.3 Macros with Arguments 368
270
6.11 String-Handling Functions in the Standard Library 8.4 The Type Definitions and Macros in stddef.h 371
272 An Example: Sorting with qsortO
6.12 Multidimensional Arrays 8.5 372
277 8.6 An Example: Macros with Arguments 377
Two-dimensional Arrays 278
The Storage Mapping Function 8.7 The Macros in stdio.h and ctype.h 382
279
Formal Parameter Declarations 8.8 Conditional Compilation 384
279 8.9 The Predefined Macros 387
Three-dimensional Arrays 280
Initialization 8.10 The Operators # and ## 387
281 8.11 The assertO Macro 388
The Use of typedef 282
6.13 Arrays of Pointers 8.12 The Use of #error and #pragma 389
284 8.13 Line Numbers 390

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy