30.00$ - Purchase this E-book
Category : Higher Education
Preface xxi 1 Introduction to Computers, the Internet and theWeb 1 1.1 Introduction 2 1.2 What Is a Computer? 4 1.3 Computer Organization 4 1.4 Early Operating Systems 5 1.5 Personal, Distributed and Client/Server Computing 6 1.6 Machine Languages, Assembly Languages and High-Level Languages 6 1.7 Fortran, COBOL, Pascal and Ada 8 1.8 History of C 8 1.9 C Standard Library 9 1.10 C++ 10 1.11 Java 11 1.12 BASIC, Visual Basic, Visual C++, Visual C# and .NET 11 1.13 Key Software Trend: Object Technology 12 1.14 Typical C Program Development Environment 13 1.15 Hardware Trends 16 1.16 History of the Internet 16 1.17 History of the World Wide Web 18 1.18 Notes About C and This Book 18 1.19 Web Resources 19 2 Introduction to C Programming 32 2.1 Introduction 33 2.2 A Simple C Program: Printing a Line of Text 33 2.3 Another Simple C Program: Adding Two Integers 37 2.4 Memory Concepts 42 2.5 Arithmetic in C 43 2.6 Decision Making: Equality and Relational Operators 47 3 Structured Program Development in C 62 3.1 Introduction 63 3.2 Algorithms 63 Contents x Contents 3.3 Pseudocode 64 3.4 Control Structures 64 3.5 The if Selection Statement 66 3.6 The if…else Selection Statement 68 3.7 The while Repetition Statement 71 3.8 Formulating Algorithms Case Study 1: Counter-Controlled Repetition 72 3.9 Formulating Algorithms with Top-Down, Stepwise Refinement Case Study 2: Sentinel-Controlled Repetition 75 3.10 Formulating Algorithms with Top-Down, Stepwise Refinement Case Study 3: Nested Control Structures 81 3.11 Assignment Operators 85 3.12 Increment and Decrement Operators 85 4 C Program Control 107 4.1 Introduction 108 4.2 Repetition Essentials 108 4.3 Counter-Controlled Repetition 109 4.4 for Repetition Statement 111 4.5 for Statement: Notes and Observations 113 4.6 Examples Using the for Statement 114 4.7 switch Multiple-Selection Statement 118 4.8 do…while Repetition Statement 124 4.9 break and continue Statements 126 4.10 Logical Operators 128 4.11 Confusing Equality (==) and Assignment (=) Operators 130 4.12 Structured Programming Summary 132 5 C Functions 151 5.1 Introduction 152 5.2 Program Modules in C 152 5.3 Math Library Functions 153 5.4 Functions 155 5.5 Function Definitions 156 5.6 Function Prototypes 160 5.7 Function Call Stack and Activation Records 162 5.8 Headers 163 5.9 Calling Functions: Call-by-Value and Call-by-Reference 164 5.10 Random Number Generation 165 5.11 Example: A Game of Chance 170 5.12 Storage Classes 174 5.13 Scope Rules 176 5.14 Recursion 179 5.15 Example Using Recursion: Fibonacci Series 183 5.16 Recursion vs. Iteration 186 Contents xi 6 C Arrays 208 6.1 Introduction 209 6.2 Arrays 209 6.3 Defining Arrays 211 6.4 Array Examples 211 6.5 Passing Arrays to Functions 225 6.6 Sorting Arrays 229 6.7 Case Study: Computing Mean, Median and Mode Using Arrays 232 6.8 Searching Arrays 235 6.9 Multiple-Subscripted Arrays 242 7 C Pointers 267 7.1 Introduction 268 7.2 Pointer Variable Definitions and Initialization 268 7.3 Pointer Operators 269 7.4 Passing Arguments to Functions by Reference 272 7.5 Using the const Qualifier with Pointers 276 7.6 Bubble Sort Using Call-by-Reference 282 7.7 sizeof Operator 285 7.8 Pointer Expressions and Pointer Arithmetic 288 7.9 Relationship between Pointers and Arrays 290 7.10 Arrays of Pointers 295 7.11 Case Study: Card Shuffling and Dealing Simulation 295 7.12 Pointers to Functions 300 8 C Characters and Strings 325 8.1 Introduction 326 8.2 Fundamentals of Strings and Characters 326 8.3 Character-Handling Library 328 8.4 String-Conversion Functions 333 8.5 Standard Input/Output Library Functions 338 8.6 String-Manipulation Functions of the String-Handling Library 343 8.7 Comparison Functions of the String-Handling Library 345 8.8 Search Functions of the String-Handling Library 347 8.9 Memory Functions of the String-Handling Library 354 8.10 Other Functions of the String-Handling Library 358 9 C Formatted Input/Output 372 9.1 Introduction 373 9.2 Streams 373 9.3 Formatting Output with printf 373 9.4 Printing Integers 374 9.5 Printing Floating-Point Numbers 376 xii Contents 9.6 Printing Strings and Characters 377 9.7 Other Conversion Specifiers 379 9.8 Printing with Field Widths and Precision 380 9.9 Using Flags in the printf Format Control String 383 9.10 Printing Literals and Escape Sequences 385 9.11 Reading Formatted Input with scanf 386 10 C Structures, Unions, Bit Manipulations and Enumerations 401 10.1 Introduction 402 10.2 Structure Definitions 402 10.3 Initializing Structures 405 10.4 Accessing Members of Structures 405 10.5 Using Structures with Functions 407 10.6 typedef 407 10.7 Example: High-Performance Card Shuffling and Dealing Simulation 408 10.8 Unions 411 10.9 Bitwise Operators 413 10.10 Bit Fields 422 10.11 Enumeration Constants 426 11 C File Processing 438 11.1 Introduction 439 11.2 Data Hierarchy 439 11.3 Files and Streams 441 11.4 Creating a Sequential-Access File 442 11.5 Reading Data from a Sequential-Access File 447 11.6 Random-Access Files 452 11.7 Creating a Random-Access File 453 11.8 Writing Data Randomly to a Random-Access File 455 11.9 Reading Data from a Random-Access File 458 11.10 Case Study: Transaction-Processing Program 459 12 C Data Structures 477 12.1 Introduction 478 12.2 Self-Referential Structures 479 12.3 Dynamic Memory Allocation 479 12.4 Linked Lists 481 12.5 Stacks 490 12.6 Queues 496 12.7 Trees 502 13 C Preprocessor 533 13.1 Introduction 534 Contents xiii 13.2 #include Preprocessor Directive 534 13.3 #define Preprocessor Directive: Symbolic Constants 535 13.4 #define Preprocessor Directive: Macros 535 13.5 Conditional Compilation 537 13.6 #error and #pragma Preprocessor Directives 538 13.7 # and ## Operators 538 13.8 Line Numbers 539 13.9 Predefined Symbolic Constants 539 13.10 Assertions 540 14 Other C Topics 545 14.1 Introduction 546 14.2 Redirecting Input/Output on Linux/UNIX and Windows Systems 546 14.3 Variable-Length Argument Lists 547 14.4 Using Command-Line Arguments 549 14.5 Notes on Compiling Multiple-Source-File Programs 551 14.6 Program Termination with exit and atexit 552 14.7 volatile Type Qualifier 554 14.8 Suffixes for Integer and Floating-Point Constants 554 14.9 More on Files 554 14.10 Signal Handling 557 14.11 Dynamic Memory Allocation: Functions calloc and realloc 559 14.12 Unconditional Branching with goto 560 15 Game Programming with the Allegro C Library 566 15.1 Introduction 567 15.2 Installing Allegro 567 15.3 A Simple Allegro Program 568 15.4 Simple Graphics: Importing Bitmaps and Blitting 569 15.5 Animation with Double Buffering 574 15.6 Importing and Playing Sounds 581 15.7 Keyboard Input 585 15.8 Fonts and Displaying Text 590 15.9 Implementing the Game of Pong 596 15.10 Timers in Allegro 602 15.11 The Grabber and Allegro Datafiles 608 15.12 Other Allegro Capabilities 616 15.13 Allegro Internet and Web Resources 617 16 Sorting: A Deeper Look 624 16.1 Introduction 625 16.2 Big O Notation 625 xiv Contents 16.3 Selection Sort 626 16.4 Insertion Sort 630 16.5 Merge Sort 633 17 Introduction to C99 644 17.1 Introduction 645 17.2 Support for C99 645 17.3 New C99 Headers 646 17.4 // Comments 647 17.5 Mixing Declarations and Executable Code 647 17.6 Declaring a Variable in a for Statement Header 649 17.7 Designated Initializers and Compound Literals 650 17.8 Type bool 653 17.9 Implicit int in Function Declarations 655 17.10 Complex Numbers 656 17.11 Variable-Length Arrays 657 17.12 Other C99 Features 659 17.13 Internet and Web Resources 661 18 C++ as a Better C; Introducing Object Technology 666 18.1 Introduction 667 18.2 C++ 667 18.3 A Simple Program: Adding Two Integers 668 18.4 C++ Standard Library 670 18.5 Header Files 671 18.6 Inline Functions 673 18.7 References and Reference Parameters 676 18.8 Empty Parameter Lists 680 18.9 Default Arguments 681 18.10 Unary Scope Resolution Operator 683 18.11 Function Overloading 684 18.12 Function Templates 687 18.13 Introduction to Object Technology and the UML 690 18.14 Wrap-Up 694 19 Introduction to Classes and Objects 701 19.1 Introduction 702 19.2 Classes, Objects, Member Functions and Data Members 702 19.3 Overview of the Chapter Examples 703 19.4 Defining a Class with a Member Function 704 19.5 Defining a Member Function with a Parameter 708 19.6 Data Members, set Functions and get Functions 711 Contents xv 19.7 Initializing Objects with Constructors 718 19.8 Placing a Class in a Separate File for Reusability 722 19.9 Separating Interface from Implementation 726 19.10 Validating Data with set Functions 732 19.11 Wrap-Up 737 20 Classes: A Deeper Look, Part 1 744 20.1 Introduction 745 20.2 Time Class Case Study 746 20.3 Class Scope and Accessing Class Members 751 20.4 Separating Interface from Implementation 753 20.5 Access Functions and Utility Functions 755 20.6 Time Class Case Study: Constructors with Default Arguments 757 20.7 Destructors 763 20.8 When Constructors and Destructors Are Called 764 20.9 Time Class Case Study: A Subtle Trap–Returning a Reference to a private Data Member 767 20.10 Default Memberwise Assignment 770 20.11 Software Reusability 772 20.12 Wrap-Up 773 21 Classes: A Deeper Look, Part 2 779 21.1 Introduction 780 21.2 const (Constant) Objects and const Member Functions 780 21.3 Composition: Objects as Members of Classes 790 21.4 friend Functions and friend Classes 797 21.5 Using the this Pointer 801 21.6 Dynamic Memory Management with Operators new and delete 806 21.7 static Class Members 808 21.8 Data Abstraction and Information Hiding 814 21.8.1 Example: Array Abstract Data Type 815 21.8.2 Example: String Abstract Data Type 816 21.8.3 Example: Queue Abstract Data Type 816 21.9 Container Classes and Iterators 817 21.10 Proxy Classes 817 21.11 Wrap-Up 821 22 Operator Overloading 827 22.1 Introduction 828 22.2 Fundamentals of Operator Overloading 829 22.3 Restrictions on Operator Overloading 830 22.4 Operator Functions as Class Members vs. Global Functions 832 xvi Contents 22.5 Overloading Stream Insertion and Stream Extraction Operators 833 22.6 Overloading Unary Operators 837 22.7 Overloading Binary Operators 837 22.8 Case Study: Array Class 838 22.9 Converting between Types 850 22.10 Overloading ++ and —— 851 22.11 explicit Constructors 852 22.12 Wrap-Up 856 23 Object-Oriented Programming: Inheritance 868 23.1 Introduction 869 23.2 Base Classes and Derived Classes 870 23.3 protected Members 873 23.4 Relationship between Base Classes and Derived Classes 873 23.4.1 Creating and Using a CommissionEmployee Class 874 23.4.2 Creating a BasePlusCommissionEmployee Class Without Using Inheritance 879 23.4.3 Creating a CommissionEmployee—BasePlusCommissionEmployee Inheritance Hierarchy 885 23.4.4 CommissionEmployee—BasePlusCommissionEmployee Inheritance Hierarchy Using protected Data 890 23.4.5 CommissionEmployee—BasePlusCommissionEmployee Inheritance Hierarchy Using private Data 897 23.5 Constructors and Destructors in Derived Classes 905 23.6 public, protected and private Inheritance 913 23.7 Software Engineering with Inheritance 913 23.8 Wrap-Up 915 24 Object-Oriented Programming: Polymorphism 921 24.1 Introduction 922 24.2 Polymorphism Examples 924 24.3 Relationships Among Objects in an Inheritance Hierarchy 925 24.3.1 Invoking Base-Class Functions from Derived-Class Objects 925 24.3.2 Aiming Derived-Class Pointers at Base-Class Objects 933 24.3.3 Derived-Class Member-Function Calls via Base-Class Pointers 934 24.3.4 Virtual Functions 936 24.3.5 Summary of the Allowed Assignments Between Base-Class and Derived-Class Objects and Pointers 942 24.4 Type Fields and switch Statements 942 24.5 Abstract Classes and Pure virtual Functions 943 24.6 Case Study: Payroll System Using Polymorphism 945 24.6.1 Creating Abstract Base Class Employee 947 24.6.2 Creating Concrete Derived Class SalariedEmployee 950 24.6.3 Creating Concrete Derived Class HourlyEmployee 952 Contents xvii 24.6.4 Creating Concrete Derived Class CommissionEmployee 955 24.6.5 Creating Indirect Concrete Derived Class BasePlusCommissionEmployee 957 24.6.6 Demonstrating Polymorphic Processing 959 24.7 (Optional) Polymorphism, Virtual Functions and Dynamic Binding “Under the Hood” 963 24.8 Case Study: Payroll System Using Polymorphism and Runtime Type Information with Downcasting, dynamic_cast, typeid and type_info 967 24.9 Virtual Destructors 970 24.10 Wrap-Up 971 25 Templates 976 25.1 Introduction 977 25.2 Function Templates 978 25.3 Overloading Function Templates 981 25.4 Class Templates 981 25.5 Nontype Parameters and Default Types for Class Templates 988 25.6 Notes on Templates and Inheritance 989 25.7 Notes on Templates and Friends 989 25.8 Notes on Templates and static Members 990 25.9 Wrap-Up 991 26 Stream Input/Output 996 26.1 Introduction 997 26.2 Streams 998 26.2.1 Classic Streams vs. Standard Streams 999 26.2.2 iostream Library Header Files 999 26.2.3 Stream Input/Output Classes and Objects 999 26.3 Stream Output 1002 26.3.1 Output of char * Variables 1002 26.3.2 Character Output Using Member Function put 1002 26.4 Stream Input 1003 26.4.1 get and getline Member Functions 1004 26.4.2 istream Member Functions peek, putback and ignore 1007 26.4.3 Type-Safe I/O 1007 26.5 Unformatted I/O Using read, write and gcount 1007 26.6 Introduction to Stream Manipulators 1008 26.6.1 Integral Stream Base: dec, oct, hex and setbase 1009 26.6.2 Floating-Point Precision (precision, setprecision) 1010 26.6.3 Field Width (width, setw) 1011 26.6.4 User-Defined Output Stream Manipulators 1013 26.7 Stream Format States and Stream Manipulators 1014 26.7.1 Trailing Zeros and Decimal Points (showpoint) 1015 26.7.2 Justification (left, right and internal) 1016 xviii Contents 26.7.3 Padding (fill, setfill) 1018 26.7.4 Integral Stream Base (dec, oct, hex, showbase) 1019 26.7.5 Floating-Point Numbers; Scientific and Fixed Notation (scientific, fixed) 1020 26.7.6 Uppercase/Lowercase Control (uppercase) 1020 26.7.7 Specifying Boolean Format (boolalpha) 1022 26.7.8 Setting and Resetting the Format State via Member Function flags 1023 26.8 Stream Error States 1024 26.9 Tying an Output Stream to an Input Stream 1027 26.10 Wrap-Up 1027 27 Exception Handling 1038 27.1 Introduction 1039 27.2 Exception-Handling Overview 1040 27.3 Example: Handling an Attempt to Divide by Zero 1040 27.4 When to Use Exception Handling 1047 27.5 Rethrowing an Exception 1048 27.6 Exception Specifications 1049 27.7 Processing Unexpected Exceptions 1050 27.8 Stack Unwinding 1051 27.9 Constructors, Destructors and Exception Handling 1052 27.10 Exceptions and Inheritance 1053 27.11 Processing new Failures 1053 27.12 Class auto_ptr and Dynamic Memory Allocation 1057 27.13 Standard Library Exception Hierarchy 1060 27.14 Other Error-Handling Techniques 1062 27.15 Wrap-Up 1062 A Internet andWeb Resources 1070 A.1 Free C/C++ Compilers and Development Tools 1070 A.2 C Resource Sites 1071 A.3 C99 1071 A.4 C Projects, Freeware and Shareware 1073 A.5 C Source Code 1073 A.6 C Articles and Whitepapers 1073 A.7 C Tutorials and Webcasts 1074 A.8 GNOME and GLib 1075 A.9 SWIG 1076 A.10 Objective-C 1076 A.11 C Sample Chapters and eBooks 1077 A.12 C Wikis 1077 A.13 C FAQs 1077 A.14 C Newsgroups 1078 Contents xix A.15 C Blogs 1078 A.16 C Downloads from Download.com 1078 A.17 C Game Programming 1078 A.18 Allegro Game Programming Resources 1079 A.19 Jobs for C Programmers 1081 A.20 Deitel C Training 1081 B Operator Precedence Charts 1082 C ASCII Character Set 1086 D Number Systems 1087 D.1 Introduction 1088 D.2 Abbreviating Binary Numbers as Octal and Hexadecimal Numbers 1091 D.3 Converting Octal and Hexadecimal Numbers to Binary Numbers 1092 D.4 Converting from Binary, Octal or Hexadecimal to Decimal 1092 D.5 Converting from Decimal to Binary, Octal or Hexadecimal 1093 D.6 Negative Binary Numbers: Two’s Complement Notation 1095 E Game Programming: Solving Sudoku 1100 Index 1109 Table of Contents
Get C How to Program, 5th Edition by Paul J. Deitel, Deitel & Associates, Inc.
0 commentaires:
Enregistrer un commentaire