For introductory courses in C Programming. Also for courses in Programming for Engineers, Programming for Business, and Programming for Technology.
The Deitels' "How to Program" series offers unparalleled breadth and depth of object-oriented programming concepts and intermediate-level topics for further study. Using the Deitels' signature "Live-Code(TM) Approach," this complete, authoritative introduction to C programming introduces fundamentals of structured programming, and covers relevant features of C language's C-201X standard. It also includes an updated treatment of C++ for those who want to transition to object-oriented concepts. Finally, new material on security is added to this edition.
Author(s): Paul Deitel; Harvey Deitel
Publisher: Prentice Hall
Year: 2012
Language: English
Pages: 945
Cover
Title Page
Copyright Page
Acknowledgments
Contents
Preface
1 Introduction to Computers, the Internet and the Web
1.1 Introduction
1.2 Computers and the Internet in Industry and Research
1.3 Hardware and Software
1.3.1 Moore’s Law
1.3.2 Computer Organization
1.4 Data Hierarchy
1.5 Programming Languages
1.6 The C Programming Language
1.7 C Standard Library
1.8 C++ and Other C-Based Languages
1.9 Object Technology
1.10 Typical C Program Development Environment
1.10.1 Phase 1: Creating a Program
1.10.2 Phases 2 and 3: Preprocessing and Compiling a C Program
1.10.3 Phase 4: Linking
1.10.4 Phase 5: Loading
1.10.5 Phase 6: Execution
1.10.6 Problems That May Occur at Execution Time
1.10.7 Standard Input, Standard Output and Standard Error Streams
1.11 Test-Driving a C Application in Windows, Linux and Mac OS X
1.11.1 Running a C Application from the Windows Command Prompt
1.11.2 Running a C Application Using GNU C with Linux
1.11.3 Running a C Application Using GNU C with Mac OS X
1.12 Operating Systems
1.12.1 Windows—A Proprietary Operating System
1.12.2 Linux—An Open-Source Operating System
1.12.3 Apple’s Mac OS X; Apple’s iOS for iPhone®, iPad® and iPod Touch® Devices
1.12.4 Google’s Android
1.13 The Internet and World Wide Web
1.14 Some Key Software Development Terminology
1.15 Keeping Up-to-Date with Information Technologies
1.16 Web Resources
2 Introduction to C Programming
2.1 Introduction
2.2 A Simple C Program: Printing a Line of Text
2.3 Another Simple C Program: Adding Two Integers
2.4 Memory Concepts
2.5 Arithmetic in C
2.6 Decision Making: Equality and Relational Operators
2.7 Secure C Programming
3 Structured Program Development in C
3.1 Introduction
3.2 Algorithms
3.3 Pseudocode
3.4 Control Structures
3.5 The if Selection Statement
3.6 The if…else Selection Statement
3.7 The while Repetition Statement
3.8 Formulating Algorithms Case Study 1: Counter-Controlled Repetition
3.9 Formulating Algorithms with Top-Down, Stepwise Refinement Case Study 2: Sentinel-Controlled Repetition
3.10 Formulating Algorithms with Top-Down, Stepwise Refinement Case Study 3: Nested Control Statements
3.11 Assignment Operators
3.12 Increment and Decrement Operators
3.13 Secure C Programming
4 C Program Control
4.1 Introduction
4.2 Repetition Essentials
4.3 Counter-Controlled Repetition
4.4 for Repetition Statement
4.5 for Statement: Notes and Observations
4.6 Examples Using the for Statement
4.7 switch Multiple-Selection Statement
4.8 do…while Repetition Statement
4.9 break and continue Statements
4.10 Logical Operators
4.11 Confusing Equality (==) and Assignment (=) Operators
4.12 Structured Programming Summary
4.13 Secure C Programming
5 C Functions
5.1 Introduction
5.2 Program Modules in C
5.3 Math Library Functions
5.4 Functions
5.5 Function Definitions
5.6 Function Prototypes: A Deeper Look
5.7 Function Call Stack and Stack Frames
5.8 Headers
5.9 Passing Arguments By Value and By Reference
5.10 Random Number Generation
5.11 Example: A Game of Chance
5.12 Storage Classes
5.13 Scope Rules
5.14 Recursion
5.15 Example Using Recursion: Fibonacci Series
5.16 Recursion vs. Iteration
5.17 Secure C Programming
6 C Arrays
6.1 Introduction
6.2 Arrays
6.3 Defining Arrays
6.4 Array Examples
6.5 Passing Arrays to Functions
6.6 Sorting Arrays
6.7 Case Study: Computing Mean, Median and Mode Using Arrays
6.8 Searching Arrays
6.9 Multidimensional Arrays
6.10 Variable-Length Arrays
6.11 Secure C Programming
7 C Pointers
7.1 Introduction
7.2 Pointer Variable Definitions and Initialization
7.3 Pointer Operators
7.4 Passing Arguments to Functions by Reference
7.5 Using the const Qualifier with Pointers
7.5.1 Converting a String to Uppercase Using a Non-Constant Pointer to Non-Constant Data
7.5.2 Printing a String One Character at a Time Using a Non-Constant Pointer to Constant Data
7.5.3 Attempting to Modify a Constant Pointer to Non-Constant Data
7.5.4 Attempting to Modify a Constant Pointer to Constant Data
7.6 Bubble Sort Using Pass-by-Reference
7.7 sizeof Operator
7.8 Pointer Expressions and Pointer Arithmetic
7.9 Relationship between Pointers and Arrays
7.10 Arrays of Pointers
7.11 Case Study: Card Shuffling and Dealing Simulation
7.12 Pointers to Functions
7.13 Secure C Programming
8 C Characters and Strings
8.1 Introduction
8.2 Fundamentals of Strings and Characters
8.3 Character-Handling Library
8.3.1 Functions isdigit, isalpha, isalnum and isxdigit
8.3.2 Functions islower, isupper, tolower and toupper
8.3.3 Functions isspace, iscntrl, ispunct, isprint and isgraph
8.4 String-Conversion Functions
8.4.1 Function strtod
8.4.2 Function strtol
8.4.3 Function strtoul
8.5 Standard Input/Output Library Functions
8.5.1 Functions fgets and putchar
8.5.2 Function getchar
8.5.3 Function sprintf
8.5.4 Function sscanf
8.6 String-Manipulation Functions of the String-Handling Library
8.6.1 Functions strcpy and strncpy
8.6.2 Functions strcat and strncat
8.7 Comparison Functions of the String-Handling Library
8.8 Search Functions of the String-Handling Library
8.8.1 Function strchr
8.8.2 Function strcspn
8.8.3 Function strpbrk
8.8.4 Function strrchr
8.8.5 Function strspn
8.8.6 Function strstr
8.8.7 Function strtok
8.9 Memory Functions of the String-Handling Library
8.9.1 Function memcpy
8.9.2 Function memmove
8.9.3 Function memcmp
8.9.4 Function memchr
8.9.5 Function memset
8.10 Other Functions of the String-Handling Library
8.10.1 Function strerror
8.10.2 Function strlen
8.11 Secure C Programming
9 C Formatted Input/Output
9.1 Introduction
9.2 Streams
9.3 Formatting Output with printf
9.4 Printing Integers
9.5 Printing Floating-Point Numbers
9.6 Printing Strings and Characters
9.7 Other Conversion Specifiers
9.8 Printing with Field Widths and Precision
9.9 Using Flags in the printf Format Control String
9.10 Printing Literals and Escape Sequences
9.11 Reading Formatted Input with scanf
9.12 Secure C Programming
10 C Structures, Unions, Bit Manipulation and Enumerations
10.1 Introduction
10.2 Structure Definitions
10.2.1 Self-Referential Structures
10.2.2 Defining Variables of Structure Types
10.2.3 Structure Tag Names
10.2.4 Operations That Can Be Performed on Structures
10.3 Initializing Structures
10.4 Accessing Structure Members
10.5 Using Structures with Functions
10.6 typedef
10.7 Example: High-Performance Card Shuffling and Dealing Simulation
10.8 Unions
10.8.1 Union Declarations
10.8.2 Operations That Can Be Performed on Unions
10.8.3 Initializing Unions in Declarations
10.8.4 Demonstrating Unions
10.9 Bitwise Operators
10.9.1 Displaying an Unsigned Integer in Bits
10.9.2 Making Function displayBits More Scalable and Portable
10.9.3 Using the Bitwise AND, Inclusive OR, Exclusive OR and Complement Operators
10.9.4 Using the Bitwise Left- and Right-Shift Operators
10.9.5 Bitwise Assignment Operators
10.10 Bit Fields
10.11 Enumeration Constants
10.12 Secure C Programming
11 C File Processing
11.1 Introduction
11.2 Files and Streams
11.3 Creating a Sequential-Access File
11.4 Reading Data from a Sequential-Access File
11.5 Random-Access Files
11.6 Creating a Random-Access File
11.7 Writing Data Randomly to a Random-Access File
11.8 Reading Data from a Random-Access File
11.9 Case Study: Transaction-Processing Program
11.10 Secure C Programming
12 C Data Structures
12.1 Introduction
12.2 Self-Referential Structures
12.3 Dynamic Memory Allocation
12.4 Linked Lists
12.4.1 Function insert
12.4.2 Function delete
12.4.3 Function printList
12.5 Stacks
12.5.1 Function push
12.5.2 Function pop
12.5.3 Applications of Stacks
12.6 Queues
12.6.1 Function enqueue
12.6.2 Function dequeue
12.7 Trees
12.7.1 Function insertNode
12.7.2 Traversals: Functions inOrder, preOrder and postOrder
12.7.3 Duplicate Elimination
12.7.4 Binary Tree Search
12.7.5 Other Binary Tree Operations
12.8 Secure C Programming
13 C Preprocessor
13.1 Introduction
13.2 #include Preprocessor Directive
13.3 #define Preprocessor Directive: Symbolic Constants
13.4 #define Preprocessor Directive: Macros
13.5 Conditional Compilation
13.6 #error and #pragma Preprocessor Directives
13.7 # and ## Operators
13.8 Line Numbers
13.9 Predefined Symbolic Constants
13.10 Assertions
13.11 Secure C Programming
14 Other C Topics
14.1 Introduction
14.2 Redirecting I/O
14.3 Variable-Length Argument Lists
14.4 Using Command-Line Arguments
14.5 Notes on Compiling Multiple-Source-File Programs
14.6 Program Termination with exit and atexit
14.7 Suffixes for Integer and Floating-Point Literals
14.8 Signal Handling
14.9 Dynamic Memory Allocation: Functions calloc and realloc
14.10 Unconditional Branching with goto
15 C++ as a Better C; Introducing Object Technology
15.1 Introduction
15.2 C++
15.3 A Simple Program: Adding Two Integers
15.4 C++ Standard Library
15.5 Header Files
15.6 Inline Functions
15.7 References and Reference Parameters
15.8 Empty Parameter Lists
15.9 Default Arguments
15.10 Unary Scope Resolution Operator
15.11 Function Overloading
15.12 Function Templates
15.13 Introduction to C++ Standard Library Class Template vector
15.14 Introduction to Object Technology and the UML
15.15 Wrap-Up
16 Introduction to Classes, Objects and Strings
16.1 Introduction
16.2 Defining a Class with a Member Function
16.3 Defining a Member Function with a Parameter
16.4 Data Members, set Functions and get Functions
16.5 Initializing Objects with Constructors
16.6 Placing a Class in a Separate File for Reusability
16.7 Separating Interface from Implementation
16.8 Validating Data with set Functions
16.9 Wrap-Up
17 Classes: A Deeper Look, Part 1
17.1 Introduction
17.2 Time Class Case Study
17.3 Class Scope and Accessing Class Members
17.4 Separating Interface from Implementation
17.5 Access Functions and Utility Functions
17.6 Time Class Case Study: Constructors with Default Arguments
17.7 Destructors
17.8 When Constructors and Destructors Are Called
17.9 Time Class Case Study: A Subtle Trap—Returning a Reference to a private Data Member
17.10 Default Memberwise Assignment
17.11 Wrap-Up
18 Classes: A Deeper Look, Part 2
18.1 Introduction
18.2 const (Constant) Objects and const Member Functions
18.3 Composition: Objects as Members of Classes
18.4 friend Functions and friend Classes
18.5 Using the this Pointer
18.6 static Class Members
18.7 Proxy Classes
18.8 Wrap-Up
19 Operator Overloading; Class string
19.1 Introduction
19.2 Using the Overloaded Operators of Standard Library Class string
19.3 Fundamentals of Operator Overloading
19.4 Overloading Binary Operators
19.5 Overloading the Binary Stream Insertion and Stream Extraction Operators
19.6 Overloading Unary Operators
19.7 Overloading the Unary Prefix and Postfix ++ and -- Operators
19.8 Case Study: A Date Class
19.9 Dynamic Memory Management
19.10 Case Study: Array Class
19.10.1 Using the Array Class
19.10.2 Array Class Definition
19.11 Operators as Member Functions vs. Non-Member Functions
19.12 Converting between Types
19.13 explicit Constructors
19.14 Building a String Class
19.15 Wrap-Up
20 Object-Oriented Programming: Inheritance
20.1 Introduction
20.2 Base Classes and Derived Classes
20.3 protected Members
20.4 Relationship between Base Classes and Derived Classes
20.4.1 Creating and Using a CommissionEmployee Class
20.4.2 Creating a BasePlusCommissionEmployee Class Without Using Inheritance
20.4.3 Creating a CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy
20.4.4 CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy Using protected Data
20.4.5 CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy Using private Data
20.5 Constructors and Destructors in Derived Classes
20.6 public, protected and private Inheritance
20.7 Software Engineering with Inheritance
20.8 Wrap-Up
21 Object-Oriented Programming: Polymorphism
21.1 Introduction
21.2 Introduction to Polymorphism: Polymorphic Video Game
21.3 Relationships Among Objects in an Inheritance Hierarchy
21.3.1 Invoking Base-Class Functions from Derived-Class Objects
21.3.2 Aiming Derived-Class Pointers at Base-Class Objects
21.3.3 Derived-Class Member-Function Calls via Base-Class Pointers
21.3.4 Virtual Functions
21.4 Type Fields and switch Statements
21.5 Abstract Classes and Pure virtual Functions
21.6 Case Study: Payroll System Using Polymorphism
21.6.1 Creating Abstract Base Class Employee
21.6.2 Creating Concrete Derived Class SalariedEmployee
21.6.3 Creating Concrete Derived Class CommissionEmployee
21.6.4 Creating Indirect Concrete Derived Class BasePlusCommissionEmployee
21.6.5 Demonstrating Polymorphic Processing
21.7 (Optional) Polymorphism, Virtual Functions and Dynamic Binding “Under the Hood”
21.8 Case Study: Payroll System Using Polymorphism and Runtime Type Information with Downcasting, dynamic_cast, typeid and type_info
21.9 Virtual Destructors
21.10 Wrap-Up
22 Templates
22.1 Introduction
22.2 Function Templates
22.3 Overloading Function Templates
22.4 Class Templates
22.5 Nontype Parameters and Default Types for Class Templates
22.6 Wrap-Up
23 Stream Input/Output
23.1 Introduction
23.2 Streams
23.2.1 Classic Streams vs. Standard Streams
23.2.2 iostream Library Headers
23.2.3 Stream Input/Output Classes and Objects
23.3 Stream Output
23.3.1 Output of char * Variables
23.3.2 Character Output Using Member Function put
23.4 Stream Input
23.4.1 get and getline Member Functions
23.4.2 istream Member Functions peek, putback and ignore
23.4.3 Type-Safe I/O
23.5 Unformatted I/O Using read, write and gcount
23.6 Introduction to Stream Manipulators
23.6.1 Integral Stream Base: dec, oct, hex and setbase
23.6.2 Floating-Point Precision (precision, setprecision)
23.6.3 Field Width (width, setw)
23.6.4 User-Defined Output Stream Manipulators
23.7 Stream Format States and Stream Manipulators
23.7.1 Trailing Zeros and Decimal Points (showpoint)
23.7.2 Justification (left, right and internal)
23.7.3 Padding (fill, setfill)
23.7.4 Integral Stream Base (dec, oct, hex, showbase)
23.7.5 Floating-Point Numbers; Scientific and Fixed Notation (scientific, fixed)
23.7.6 Uppercase/Lowercase Control (uppercase)
23.7.7 Specifying Boolean Format (boolalpha)
23.7.8 Setting and Resetting the Format State via Member Function flags
23.8 Stream Error States
23.9 Tying an Output Stream to an Input Stream
23.10 Wrap-Up
24 Exception Handling: A Deeper Look
24.1 Introduction
24.2 Example: Handling an Attempt to Divide by Zero
24.3 When to Use Exception Handling
24.4 Rethrowing an Exception
24.5 Processing Unexpected Exceptions
24.6 Stack Unwinding
24.7 Constructors, Destructors and Exception Handling
24.8 Exceptions and Inheritance
24.9 Processing new Failures
24.10 Class unique_ptr and Dynamic Memory Allocation
24.11 Standard Library Exception Hierarchy
24.12 Wrap-Up
A: Operator Precedence Charts
B: ASCII Character Set
C: Number Systems
C.1 Introduction
C.2 Abbreviating Binary Numbers as Octal and Hexadecimal Numbers
C.3 Converting Octal and Hexadecimal Numbers to Binary Numbers
C.4 Converting from Binary, Octal or Hexadecimal to Decimal
C.5 Converting from Decimal to Binary, Octal or Hexadecimal
C.6 Negative Binary Numbers: Two’s Complement Notation
D: Game Programming: Solving Sudoku
D.1 Introduction
D.2 Deitel Sudoku Resource Center
D.3 Solution Strategies
D.4 Programming Sudoku Puzzle Solvers
D.5 Generating New Sudoku Puzzles
D.6 Conclusion
Appendices on the Web
Index
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z