![]() ![]() |
C语言大学教程(第八版)(英文版) 读者对象:本书不仅适合于初学者学习,作为高校计算机程序设计教学的双语教材,也同样适用于有经验的程序员,作为软件开发人员的专业参考书。
本书是全球优秀的C语言教程之一。全书系统地介绍了4种当今流行的程序设计方法——面向过程、基于对象、面向对象以及泛型编程,内容全面、生动、易懂,作者由浅入深地介绍了结构化编程及软件工程的基本概念,从简单概念到最终完整的语言描述,清晰、准确、透彻、详细地讲解了C语言,尤其注重程序设计思想和方法的介绍。相比上一版,这一版在内容方面新增加了安全的C程序设计、提高练习题,更新了C++和面向对象程序设计、基于Allegro的游戏编程、C99标准介绍等内容。
Paul Deitel,Deitel & Associates公司CEO兼CTO,具有超过35年计算机行业的工作经验,毕业于麻省理工学院。他拥有Java Certified Programmer和Java Certified Developer认证证书,并且被授予Oracle Java Champion称号。通过Deitel & Associates公司,他向行业客户提供了数以百计的编程课程,这些客户包括:Cisco,IBM, Siemens,Sun Microsystems(现在属于Oracle),Dell,Fidelity,NASA肯尼迪航天中心,美国国家风暴实验室,白沙导弹基地,Rogue Wave Software,Boeing,SunGard Higher Education,Nortel Networks,Puma,iRobot,Invensys,等等。他和合作者Harvey Deitel博士,是全球畅销的编程语言教材和专业图书/视频产品的作者。Harvey Deitel博士,Deitel & Associates公司主席兼首席战略官,具有55年以上的计算机行业工作经验。Deitel博士在麻省理工学院获得电子工程学士和硕士学位,在波士顿大学获得数学博士学位——在将计算机科学专业从这些专业分离出去之前,Deitel博士已经学习过计算机知识。他具有丰富的大学教学经验,在与儿子Paul于1991年创立Deitel & Associates公司之前,Deitel博士是波士顿大学计算机科学系主任并获得了终身教职。他们的出版物已经赢得了国际声誉,并被翻译成了日文、德文、俄文、西班牙文、法文、波兰文、意大利文、简体中文、繁体中文、韩文、葡萄牙文、希腊文、乌尔都文和土耳其文。Deitel博士为许多大公司、学术机构、政府部门和军队提供了数百场的专业编程培训。
Paul Deitel,Deitel & Associates公司CEO兼CTO,具有超过35年计算机行业的工作经验,毕业于麻省理工学院。他拥有Java Certified Programmer和Java Certified Developer认证证书,并且被授予Oracle Java Champion称号。通过Deitel & Associates公司,他向行业客户提供了数以百计的编程课程,这些客户包括:Cisco,IBM, Siemens,Sun Microsystems(现在属于Oracle),Dell,Fidelity,NASA肯尼迪航天中心,美国国家风暴实验室,白沙导弹基地,Rogue Wave Software,Boeing,SunGard Higher Education,Nortel Networks,Puma,iRobot,Invensys,等等。他和合作者Harvey Deitel博士,是全球畅销的编程语言教材和专业图书/视频产品的作者。Harvey Deitel博士,Deitel & Associates公司主席兼首席战略官,具有55年以上的计算机行业工作经验。Deitel博士在麻省理工学院获得电子工程学士和硕士学位,在波士顿大学获得数学博士学位——在将计算机科学专业从这些专业分离出去之前,Deitel博士已经学习过计算机知识。他具有丰富的大学教学经验,在与儿子Paul于1991年创立Deitel & Associates公司之前,Deitel博士是波士顿大学计算机科学系主任并获得了终身教职。他们的出版物已经赢得了国际声誉,并被翻译成了日文、德文、俄文、西班牙文、法文、波兰文、意大利文、简体中文、繁体中文、韩文、葡萄牙文、希腊文、乌尔都文和土耳其文。Deitel博士为许多大公司、学术机构、政府部门和军队提供了数百场的专业编程培训。
目?录
1?Introduction to Computers, the Internet and the Web 计算机、因特网和万维网导论 33 1.1?Introduction 引言 34 1.2?Hardware and Software 计算机硬件和软件 35 1.3?Data Hierarchy 数据的层次结构 37 1.4?Machine Languages, Assembly Languages and High-Level Languages 机器语言、汇编语言和高级语言 40 1.5?The C Programming Language C程序设计语言 41 1.6?C Standard Library C标准库 42 1.7?C++ and Other C-Based Languages? C++和其他基于C的程序设计语言 43 1.8?Object Technology 对象技术 44 1.9?Typical C Program-Development Environment 典型的C程序开发环境 47 1.10?Test-Driving a C Application in Windows, Linux and Mac OS X 在Windows、Linux和Mac OS X上测试并运行一个C应用程序 49 1.11?Operating Systems 操作系统 59 1.12?The Internet and World Wide Web 因特网和万维网 61 1.13?Some Key Software Terminology 一些重要的软件术语 64 1.14?Keeping Up-to-Date with Information Technologies 跟上信息技术的发展 66 2?Introduction to C Programming C程序设计入门 71 2.1?Introduction 引言 72 2.2?A Simple C Program: Printing a Line of Text 一个简单的C程序:打印一行文字 72 2.3?Another Simple C Program: Adding Two Integers 另一个简单的C程序:两个整数求和 76 2.4?Memory Concepts 存储单元的基本概念 80 2.5?Arithmetic in C C语言中的算术运算 81 2.6?Decision Making: Equality and Relational Operators 做出决策:相等和关系运算符 85 2.7?Secure C Programming 安全的C程序设计 89 3?Structured Program Development in C 结构化的C程序设计 101 3.1?Introduction 引言 102 3.2?Algorithms 算法 102 3.3?Pseudocode 伪代码 102 3.4?Control Structures 控制结构 103 3.5?The if Selection Statement if条件语句 105 3.6?The if…else Selection Statement if…else条件语句 106 3.7?The while Iteration Statement while循环语句 110 3.8?Formulating Algorithms Case Study 1: Counter-Controlled Iteration 算法设计案例1:计数控制的循环 111 3.9?Formulating Algorithms with Top-Down, Stepwise Refinement Case Study 2: Sentinel-Controlled Iteration 自顶向下、逐步求精的算法设计案例2:标记控制的循环 114 3.10?Formulating Algorithms with Top-Down, Stepwise Refinement Case Study 3: Nested Control Statements 自顶向下、逐步求精的算法设计案例3:嵌套控制结构 120 3.11?Assignment Operators 赋值运算符 124 3.12?Increment and Decrement Operators 增1和减1运算符 125 3.13?Secure C Programming 安全的C程序设计 127 4?C Program Control C程序控制 145 4.1?Introduction 引言 146 4.2?Iteration Essentials 循环的基本原理 146 4.3?Counter-Controlled Iteration 计数控制的循环 147 4.4?for Iteration Statement for循环语句 148 4.5?for Statement: Notes and Observations for语句:注意事项 151 4.6?Examples Using the for Statement 使用 for语句的例子 152 4.7?switch Multiple-Selection Statement switch多重选择语句 155 4.8?do…while Iteration Statement do…while循环语句 161 4.9?break and continue Statements break和continue语句 162 4.10?Logical Operators 逻辑运算符 164 4.11?Confusing Equality (=?=) and Assignment (=) Operators 区分相等运算符(=?=)和赋值运算符(=) 167 4.12?Structured Programming Summary 结构化程序设计小结 169 4.13?Secure C Programming 安全的C程序设计 174 5?C Functions C函数 189 5.1?Introduction 引言 190 5.2?Modularizing Programs in C C语言中的程序模块 190 5.3?Math Library Functions 数学库函数 191 5.4?Functions 函数 193 5.5?Function Definitions 函数定义 193 5.6?Function Prototypes: A Deeper Look 函数原型:深入学习 198 5.7?Function Call Stack and Stack Frames 函数调用堆栈及活动记录堆栈帧 200 5.8?Headers 头文件 204 5.9?Passing Arguments By Value and By Reference 按值或按引用传递参数 205 5.10?Random Number Generation 随机数的生成 206 5.11?Example: A Game of Chance; Introducing enum 案例分析:运气游戏;引入enum 210 5.12?Storage Classes 存储类型 214 5.13?Scope Rules 作用域的规定 216 5.14?Recursion 递归 219 5.15?Example Using Recursion: Fibonacci Series 递归应用案例:Fibonacci数列 222 5.16?Recursion vs. Iteration 递归与迭代 226 5.17?Secure C Programming 安全的C程序设计 227 6?C Arrays C数组 246 6.1?Introduction 引言 247 6.2?Arrays 数组 247 6.3?Defining Arrays 数组定义 249 6.4?Array Examples 数组实例 249 6.5?Using Character Arrays to Store and Manipulate Strings 用字符数组来存储和处理字符串 257 6.6?Static Local Arrays and Automatic Local Arrays 静态局部数组和自动局部数组 260 6.7?Passing Arrays to Functions 将数组传递给函数 262 6.8?Sorting Arrays 数组排序 266 6.9?Case Study: Computing Mean, Median and Mode Using Arrays 案例分析:用数组来计算平均值、中值和众数 268 6.10?Searching Arrays 数组查找 273 6.11?Multidimensional Arrays 多下标数组 278 6.12?Variable-Length Arrays 可变长数组 285 6.13?Secure C Programming 安全的C程序设计 288 7?C Pointers C指针 306 7.1?Introduction 引言 307 7.2?Pointer Variable Definitions and Initialization 指针变量的定义和初始化 308 7.3?Pointer Operators 指针运算符 309 7.4?Passing Arguments to Functions by Reference 按引用向函数传递实参 311 7.5?Using the const Qualifier with Pointers 对指针使用const限定符 315 7.6?Bubble Sort Using Pass-by-Reference 采用按引用传递的冒泡排序 321 7.7?sizeof Operator sizeof运算符 324 7.8?Pointer Expressions and Pointer Arithmetic 指针表达式和指针算术运算 327 7.9?Relationship between Pointers and Arrays 指针和数组的关系 330 7.10?Arrays of Pointers 指针数组 334 7.11?Case Study: Card Shuffling and Dealing Simulation 案例研究:模拟扑克牌的洗牌和发牌 335 7.12?Pointers to Functions 指向函数的指针 340 7.13?Secure C Programming 安全的C程序设计 345 8?C Characters and Strings C字符和字符串 365 8.1?Introduction 引言 366 8.2?Fundamentals of Strings and Characters 字符串和字符基础 366 8.3?Character-Handling Library 字符处理函数库 368 8.4?String-Conversion Functions 字符串转换函数 374 8.5?Standard Input/Output Library Functions 标准输入/输出库函数 376 8.6?String-Manipulation Functions of the String-Handling Library 字符串处理函数库中的字符串处理函数 381 8.7?Comparison Functions of the String-Handling Library 字符串处理函数库中的比较函数 383 8.8?Search Functions of the String-Handling Library 字符串处理函数库中的查找函数 385 8.9?Memory Functions of the String-Handling Library 字符串处理函数库中的内存处理函数 391 8.10?Other Functions of the String-Handling Library 字符串处理函数库中的其他函数 395 8.11?Secure C Programming 安全的C程序设计 397 9?C Formatted Input/Output C格式化输入/输出 409 9.1?Introduction 引言 410 9.2?Streams 流 410 9.3?Formatting Output with printf 用printf函数实现格式化输出 410 9.4?Printing Integers 打印整数 411 9.5?Printing Floating-Point Numbers 打印浮点数 412 9.6?Printing Strings and Characters 打印字符串或字符 414 9.7?Other Conversion Specifiers 其他的转换说明符 415 9.8?Printing with Field Widths and Precision 带域宽和精度的打印 416 9.9?Using Flags in the printf Format Control String 在printf函数的格式控制字符串中使用标记 419 9.10?Printing Literals and Escape Sequences 打印文本和转义序列 422 9.11?Reading Formatted Input with scanf 用scanf函数读取格式化的输入 422 9.12?Secure C Programming 安全的C程序设计 429 10?C Structures, Unions, Bit Manipulation and Enumerations C结构体、共用体、位操作和枚举类型 436 10.1?Introduction 引言 437 10.2?Structure Definitions 结构体的定义 437 10.3?Initializing Structures 结构体的初始化 440 10.4?Accessing Structure Members with . and -> 用.和->访问结构体成员 440 10.5?Using Structures with Functions 在函数中使用结构体 442 10.6?typedef typedef的使用 443 10.7?Example: High-Performance Card Shuffling and Dealing Simulation 实例分析:高性能的洗牌与发牌模拟 443 10.8?Unions 共用体 446 10.9?Bitwise Operators 位运算符 448 10.10?Bit Fields 位域 457 10.11?Enumeration Constants 枚举常量 460 10.12?Anonymous Structures and Unions 匿名的结构体和共用体 462 10.13?Secure C Programming 安全的C程序设计 462 11?C File Processing C文件处理 473 11.1?Introduction 引言 474 11.2?Files and Streams 文件与流 474 11.3?Creating a Sequential-Access File 顺序存取文件的创建 475 11.4?Reading Data from a Sequential-Access File 从顺序存取文件中读取数据 481 11.5?Random-Access Files 随机存取文件 486 11.6?Creating a Random-Access File 随机存取文件的创建 486 11.7?Writing Data Randomly to a Random-Access File 随机地向一个随机存取文件中写入数据 488 11.8?Reading Data from a Random-Access File 从一个随机存取文件中读取数据 491 11.9?Case Study: Transaction-Processing Program 案例研究:事务处理程序 493 11.10?Secure C Programming 安全的C程序设计 498 12?C Data Structures C数据结构 509 12.1?Introduction 引言 510 12.2?Self-Referential Structures 自引用结构体 511 12.3?Dynamic Memory Allocation 动态内存分配 511 12.4?Linked Lists 链表 512 12.5?Stacks 堆栈 521 12.6?Queues 队列 527 12.7?Trees 树 533 12.8?Secure C Programming 安全的C程序设计 538 13?C Preprocessor C预处理 550 13.1?Introduction 引言 551 13.2?#include Preprocessor Directive #include预处理命令 551 13.3?#define Preprocessor Directive: Symbolic Constants #define预处理命令:符号常量 552 13.4?#define Preprocessor Directive: Macros #define预处理命令:宏 553 13.5?Conditional Compilation 条件编译 555 13.6?#error and #pragma Preprocessor Directives #error和#pragma预处理命令 556 13.7?# and ## Operators #和##运算符 556 13.8?Line Numbers 行号 557 13.9?Predefined Symbolic Constants 预定义的符号常量 557 13.10?Assertions 断言 558 13.11?Secure C Programming 安全的C程序设计 558 14?Other C Topics C语言的其他专题 563 14.1?Introduction 引言 564 14.2?Redirecting I/O I/O的重定向 564 14.3?Variable-Length Argument Lists 可变长的参数列表 565 14.4?Using Command-Line Arguments 使用命令行实参 567 14.5?Compiling Multiple-Source-File Programs 编译由多个源文件组成的程序 569 14.6?Program Termination with exit and atexit 使用exit和atexit终止程序 570 14.7?Suffixes for Integer and Floating-Point Literals 整型和浮点型常量的后缀 572 14.8?Signal Handling 信号处理 572 14.9?Dynamic Memory Allocation: Functions calloc and realloc 动态内存分配:函数calloc和realloc 575 14.10?Unconditional Branching with goto 用goto实现无条件转移 575 15?C++ as a Better C; Introducing Object Technology C++,一个更好的C;介绍对象技术 581 15.1?Introduction 引言 582 15.2?C++ C++语言 582 15.3?A Simple Program: Adding Two Integers 简单程序:两个整数相加 583 15.4?C++ Standard Library C++标准库 586 15.5?Header Files 头文件 586 15.6?Inline Functions 内联函数 588 15.7?C++ Keywords C++关键字 590 15.8?References and Reference Parameters 引用和引用形参 591 15.9?Empty Parameter Lists 空形参列表 596 15.10?Default Arguments 默认实参 596 15.11?Unary Scope Resolution Operator 一元作用域运算符 598 15.12?Function Overloading 函数重载 599 15.13?Function Templates 函数模板 602 15.14?Introduction to Object Technology and the UML 对象技术与UML简介 605 15.15?Introduction to C++ Standard Library Class Template vector C++标准库类模板vector简介 608 15.16?Wrap-Up 本章小结 615 16?Introduction to Classes, Objects and Strings 类、对象和字符串简介 621 16.1?Introduction 引言 622 16.2?Defining a Class with a Member Function 定义一个具有成员函数的类 622 16.3?Defining a Member Function with a Parameter 定义一个有参成员函数 625 16.4?Data Members, set Member Functions and get Member Functions 数据成员,set成员函数与get成员函数 629 16.5?Initializing Objects with Constructors 用构造函数初始化对象 634 16.6?Placing a Class in a Separate File for Reusability 将类放在单独的文件中以增强重用性 638 16.7?Separating Interface from Implementation 将接口与实现分离 642 16.8?Validating Data with set Functions 用set函数验证数据 647 16.9?Wrap-Up 本章小结 652 17?Classes: A Deeper Look; Throwing Exceptions 类:深入学习;抛出异常 659 17.1?Introduction 引言 660 17.2?Time Class Case Study Time类的案例学习 661 17.3?Class Scope and Accessing Class Members 类域和访问类的成员 667 17.4?Access Functions and Utility Functions 访问函数和工具函数 668 17.5?Time Class Case Study: Constructors with Default Arguments Time类的案例学习:具有默认实参的构造函数 669 17.6?Destructors 析构函数 675 17.7?When Constructors and Destructors Are Called 构造函数与析构函数的调用时间 675 17.8?Time Class Case Study: A Subtle Trap—Returning a Reference or a Pointer to a private Data Member Time类的案例学习:隐蔽陷阱——返回private数据成员的引用或 指针 679 17.9?Default Memberwise Assignment 默认按成员赋值 682 17.10?const Objects and const Member Functions const对象和const成员函数 684 17.11?Composition: Objects as Members of Classes 组合:对象作为类的成员 686 17.12?friend Functions and friend Classes 友元函数和友元类 692 17.13?Using the this Pointer 使用this指针 694 17.14?static Class Members static类成员 700 17.15?Wrap-Up 本章小结 705 18?Operator Overloading; Class string 运算符重载;string类 715 18.1?Introduction 引言 716 18.2?Using the Overloaded Operators of Standard Library Class string 使用标准库模板类string中的重载运算符 717 18.3?Fundamentals of Operator Overloading 运算符重载基础 720 18.4?Overloading Binary Operators 重载二元运算符 721 18.5?Overloading the Binary Stream Insertion and Stream Extraction Operators 重载流插入和流读取运算符 722 18.6?Overloading Unary Operators 重载一元运算符 726 18.7?Overloading the Unary Prefix and Postfix ++ and –?– Operators 重载一元前置和后置++和–?–运算符 727 18.8?Case Study: A Date Class 案例学习:Date类 728 18.9?Dynamic Memory Management 动态内存管理 733 18.10?Case Study: Array Class 案例学习:Array类 735 18.11?Operators as Member vs. Non-Member Functions 作为类的成员和作为非成员函数的运算符函数的比较 748 18.12?Converting Between Types 类型转换 748 18.13?explicit Constructors and Conversion Operators explicit构造函数和转换运算符 750 18.14?Overloading the Function Call Operator ( ) 重载函数调用运算符( ) 752 18.15?Wrap-Up 本章小结 753 19?Object-Oriented Programming: Inheritance 面向对象编程:继承 764 19.1?Introduction 引言 765 19.2?Base Classes and Derived Classes 基类和派生类 765 19.3?Relationship between Base and Derived Classes 基类和派生类的关系 768 19.4?Constructors and Destructors in Derived Classes 派生类的构造函数与析构函数 791 19.5?public, protected and private Inheritance public、protected和private继承 793 19.6?Software Engineering with Inheritance 关于继承的软件工程 794 19.7?Wrap-Up 本章小结 794 20?Object-Oriented Programming: Polymorphism 面向对象编程:多态 799 20.1?Introduction 引言 800 20.2?Introduction to Polymorphism: Polymorphic Video Game 多态简介:多态的视频游戏 801 20.3?Relationships Among Objects in an Inheritance Hierarchy 继承层次结构中对象间的关系 801 20.4?Type Fields and switch Statements 类型域和switch语句 815 20.5?Abstract Classes and Pure virtual Functions 抽象类和纯虚函数 815 20.6?Case Study: Payroll System Using Polymorphism 案例学习:利用多态的工资系统 817 20.7?(Optional) Polymorphism, Virtual Functions and Dynamic Binding “Under the Hood” (选讲)多态、虚函数及动态联编的“幕后机制” 832 20.8?Case Study: Payroll System Using Polymorphism and Runtime Type Information with Downcasting, dynamic_cast, typeid and type_info 案例学习:利用多态和运行时类型信息的工资系统,具有向下类型转换,使用dynamic_cast、typeid及type_info 835 20.9?Wrap-Up 本章小结 839 21?Stream Input/Output: A Deeper Look 输入/输出流:深入学习 844 21.1?Introduction 引言 845 21.2?Streams 流 846 21.3?Stream Output 输出流 849 21.4?Stream Input 输入流 851 21.5?Unformatted I/O Using read, write and gcount 用read、write和gcount进行无格式I/O 854 21.6?Introduction to Stream Manipulators 流操纵符简介 855 21.7?Stream Format States and Stream Manipulators 流格式状态和流操纵符 860 21.8?Stream Error States 流错误状态 869 21.9?Tying an Output Stream to an Input Stream 将输出流绑定到输入流上 872 21.10?Wrap-Up 本章小结 872 22?Exception Handling: A Deeper Look 异常处理:深入学习 881 22.1?Introduction 引言 882 22.2?Example: Handling an Attempt to Divide by Zero 实例:处理除数为0的异常 882 22.3?Rethrowing an Exception 重新抛出异常 888 22.4?Stack Unwinding 栈展开 889 22.5?When to Use Exception Handling 何时使用异常处理 891 22.6?Constructors, Destructors and Exception Handling 构造函数、析构函数与异常处理 892 22.7?Exceptions and Inheritance 异常与继承 893 22.8?Processing new Failures 处理new故障 893 22.9?Class unique_ptr and Dynamic Memory Allocation unique_ptr类与动态内存分配 896 22.10?Standard Library Exception Hierarchy 标准库的异常层次结构 899 22.11?Wrap-Up 本章小结 900 23?Introduction to Custom Templates 模板 906 23.1?Introduction 引言 907 23.2?Class Templates 类模板 907 23.3?Function Template to Manipulate a Class-Template Specialization Object 函数模板操纵类——模板的特化对象 912 23.4?Nontype Parameters 非类型形参 914 23.5?Default Arguments for Template Type Parameters 模板类型形参的默认实参 914 23.6?Overloading Function Templates 重载函数模板 915 23.7?Wrap-Up 本章小结 915 A?C and C++ Operator Precedence Charts 附录A 运算符优先级表 918 B?ASCII Character Set 附录B ASCII字符集 922 C?Number Systems 附录C 数值系统 923 D?Sorting: A Deeper Look 附录D 排序:深入学习 936 E?Multithreading and Other C11 and C99 Topics 附录E 多线程及其他C11和C99专题 956 Appendices on the Web 在线附录 983 Index 索引 984
你还可能感兴趣
我要评论
|