Paul Deitel和Harvey Deitel是全球畅销的编程语言教材和专业图书作家,How to Program系列是其最负盛名的一套计算机编程教材,已经销售近40年,并被翻译成中文在内的十几种语言。他们成立的Deitel & Associates公司是一家国际知名的企业培训和写作公司,专门进行计算机编程语言、对象技术、移动应用开发及Internet和Web软件技术方面的培训和写作,出版了一流的编程专业的大学教材、 专业图书以及LiveLessons视频课程。
Paul Deitel和Harvey Deitel是全球畅销的编程语言教材和专业图书作家,How to Program系列是其最负盛名的一套计算机编程教材,已经销售近40年,并被翻译成中文在内的十几种语言。他们成立的Deitel & Associates公司是一家国际知名的企业培训和写作公司,专门进行计算机编程语言、对象技术、移动应用开发及Internet和Web软件技术方面的培训和写作,出版了一流的编程专业的大学教材、 专业图书以及LiveLessons视频课程。
目錄:
Contents
Chapter 1Introduction to Computers, the Internet and the Web1
1.1Introduction2
1.2Computers and the Internet in Industry and Research2
1.3Hardware and Software4
1.4Data Hierarchy6
1.5Programming Languages7
1.6The C Programming Language7
1.7C Standard Library9
1.8C and Other C-Based Languages9
1.9Object Technology10
1.10Typical C Program Development Environment12
1.11Test-Driving a C Application in Windows, Linux and Mac OS X14
1.12Operating Systems21
1.13The Internet and World Wide Web23
1.14Some Key Software Development Terminology24
1.15Keeping Up-to-Date with Information Technologies25
1.16Web Resources26
Chapter 2Introduction to C Programming32
2.1Introduction32
2.2A Simple C Program: Printing a Line of Text32
2.3Another Simple C Program: Adding Two Integers36
2.4Memory Concepts39
2.5Arithmetic in C40
2.6Decision Making: Equality and Relational Operators43
2.7Secure C Programming46
Chapter 3Structured Program Development in C58
3.1Introduction58
3.2Algorithms59
3.3Pseudocode59
3.4Control Structures59
3.5The if Selection Statement61
3.6The ifelse Selection Statement62
3.7The while Repetition Statement65
3.8Formulating Algorithms Case Study 1: CounterControlled Repetition66
3.9Formulating Algorithms with Top-Down, Stepwise Refinement Case Study 2:
Sentinel-Controlled Repetition67
3.10Formulating Algorithms with Top-Down, Stepwise Refinement Case Study 3:
Nested Control Statements72
3.11Assignment Operators75
3.12Increment and Decrement Operators76
3.13Secure C Programming78
Chapter 4C Program Control95
4.1Introduction95
4.2Repetition Essentials96
4.3Counter-Controlled Repetition96
4.4for Repetition Statement98
4.5for Statement: Notes and Observations100
4.6Examples Using the for Statement100
4.7switch Multiple-Selection Statement103
4.8dowhile Repetition Statement108
4.9break and continue Statements109
4.10Logical Operators111
4.11Confusing Equality == and Assignment = Operators113
4.12Structured Programming Summary114
4.13Secure C Programming118
Chapter 5C Functions132
5.1Introduction133
5.2Program Modules in C133
5.3Math Library Functions134
5.4Functions135
5.5Function Definitions135
5.6Function Prototypes: A Deeper Look139
5.7Function Call Stack and Stack Frames141
5.8Headers143
5.9Passing Arguments By Value and By Reference144
5.10Random Number Generation145
5.11Example: A Game of Chance148
5.12Storage Classes151
5.13Scope Rules152
5.14Recursion155
5.15Example Using Recursion: Fibonacci Series158
5.16Recursion vs. Iteration160
5.17Secure C Programming162
Chapter 6C Arrays181
6.1Introduction181
6.2Arrays182
6.3Defining Arrays182
6.4Array Examples183
6.5Passing Arrays to Functions193
6.6Sorting Arrays196
6.7Case Study: Computing Mean, Median and Mode Using Arrays198
6.8Searching Arrays202
6.9Multidimensional Arrays206
6.10Variable-Length Arrays211
6.11Secure C Programming213
Chapter 7C Pointers230
7.1Introduction231
7.2Pointer Variable Definitions and Initialization231
7.3Pointer Operators232
7.4Passing Arguments to Functions by Reference233
7.5Using the const Qualifier with Pointers235
7.6Bubble Sort Using Pass-by-Reference241
7.7sizeof Operator243
7.8Pointer Expressions and Pointer Arithmetic245
7.9Relationship between Pointers and Arrays247
7.10Arrays of Pointers250
7.11Case Study: Card Shuffling and Dealing Simulation251
7.12Pointers to Functions254
7.13Secure C Programming258
Chapter 8C Characters and Strings277
8.1Introduction278
8.2Fundamentals of Strings and Characters278
8.3Character-Handling Library280
8.4String-Conversion Functions284
8.5Standard InputOutput Library Functions286
8.6String-Manipulation Functions of the StringHandling Library289
8.7Comparison Functions of the String-Handling Library291
8.8Search Functions of the String-Handling Library292
8.9Memory Functions of the String-Handling Library297
8.10Other Functions of the String-Handling Library300
8.11Secure C Programming301
Chapter 9C Formatted InputOutput314
9.1Introduction314
9.2Streams315
9.3Formatting Output with printf315
9.4Printing Integers315
9.5Printing Floating-Point Numbers316
9.6Printing Strings and Characters318
9.7Other Conversion Specifiers318
9.8Printing with Field Widths and Precision319
9.9Using Flags in the printf Format Control String321
9.10Printing Literals and Escape Sequences323
9.11Reading Formatted Input with scanf323
9.12Secure C Programming328
Chapter 10C Structures, Unions, Bit Manipulation and Enumerations335
10.1Introduction336
10.2Structure Definitions336
10.3Initializing Structures338
10.4Accessing Structure Members338
10.5Using Structures with Functions340
10.6typedef340
10.7Example: High-Performance Card Shuffling and Dealing Simulation341
10.8Unions343
10.9Bitwise Operators344
10.10Bit Fields351
10.11Enumeration Constants353
10.12Secure C Programming355
Chapter 11C File Processing365
11.1Introduction365
11.2Files and Streams366
11.3Creating a Sequential-Access File366
11.4Reading Data from a Sequential-Access File370
11.5Random-Access Files373
11.6Creating a Random-Access File374
11.7Writing Data Randomly to a Random-Access File375
11.8Reading Data from a Random-Access File377
11.9Case Study: Transaction-Processing Program379
11.10Secure C Programming383
Chapter 12C Data Structures393
12.1Introduction394
12.2Self-Referential Structures394
12.3Dynamic Memory Allocation395
12.4Linked Lists396
12.5Stacks402
12.6Queues406
12.7Trees411
12.8Secure C Programming415
Chapter 13C Preprocessor427
13.1Introduction427
13.2#include Preprocessor Directive428
13.3#define Preprocessor Directive: Symbolic Constants428
13.4#define Preprocessor Directive: Macros429
13.5Conditional Compilation430
13.6#error and #pragma Preprocessor Directives431
13.7# and ## Operators432
13.8Line Numbers432
13.9Predefined Symbolic Constants432
13.10Assertions433
13.11Secure C Programming433
Chapter 14Other C Topics438
14.1Introduction438
14.2Redirecting IO438
14.3Variable-Length Argument Lists439
14.4Using Command-Line Arguments441
14.5Notes on Compiling Multiple-Source-File Programs442
14.6Program Termination with exit and atexit443
14.7Suffixes for Integer and Floating-Point Literals444
14.8Signal Handling445
14.9Dynamic Memory Allocation: Functions calloc and realloc447
14.10Unconditional Branching with goto447
Chapter 15C as a Better C; Introducing Object Technology453
15.1Introduction454
15.2C454
15.3A Simple Program: Adding Two Integers454
15.4C Standard Library456
15.5Header Files457
15.6Inline Functions458
15.7References and Reference Parameters460
15.8Empty Parameter Lists464
15.9Default Arguments464
15.10Unary Scope Resolution Operator466
15.11Function Overloading467
15.12Function Templates469
15.13Introduction to C Standard Library Class Template vector471
15.14Introduction to Object Technology and the UML476
15.15Wrap-Up479
Chapter 16Introduction to Classes, Objects and Strings
內容試閱:
Preface
Welcome to the C programming languageand to C, too! This book presents leadingedge computing technologies for college students, instructors and software development professionals.
At the heart of the book is the Deitel signature live-code approach. We present concepts in the context of complete working programs, rather than in code snippets. Each code example is followed by one or more sample executions. Read the online Before You Begin section www.deitel.combookschtp7chtp7_ BYB.pdf to learn how to set up your computer to run the hundreds of code examples. All the source code is available at www.deitel.combooks chtp7 and www.pearsoninternationaleditions.comdeitel . Use the source code we provide to run every program as you study it.
We believe that this book and its support materials will give you an informative, challenging and entertaining introduction to C. As you read the book, if you have questions, send an e-mail to deitel@deitel.comwell respond promptly. For book updates, visit www.deitel.combookschtp7, join our communities on Facebook www.deitel.comdeitelfan, Twitter @deitel and Googlegplus.todeitel, and subscribe to the Deitel Buzz Online newsletter www.deitel.comnewsletter subscribe.html.
New and Updated Features
Here are some key features of C How to Program, 7e:
? Coverage of the New C standard. The previous edition of the book conformed to standard C and included a detailed appendix on the C99 standard. The New C Standard was approved just before C How to Program, 7e went to publication. The new standard incorporates both C99 and the more recent C1Xnow referred to as C11 or simply the C standard since its approval in 2011. Support for the new standard varies by compiler. The vast majority of our readership uses either the GNU gcc compilerwhich supports several of the key features in the new standardor the Microsoft Visual C compiler. Microsoft supports only a limited subset of the features that were added to C in C99 and C11primarily the features that are also required by the C standard. To accommodate all of our readers, we placed the discussion of the new standard in optional, easy-to-use-or-omit sections and in Appendix F, Introduction to the New C Standard. Weve also replaced various deprecated capabilities with newer preferred versions as a result of the new C standard.
? New Chapter 1. The new Chapter 1 engages students with intriguing facts and figures to get them excited about studying computers and computer programming. The chapter includes a table of some of the research made possible by computers and the Internet, current technology trends and hardware discussion, the data hierarchy, a new section on social networking, a table of business and technology publications and websites that will help you stay up to date with the latest technology news and trends, and updated exercises. Weve included test-drives that show how to run a command-line C program on Microsoft Windows, Linux and Mac OS X.
? Secure C Programming Sections. Weve added notes about secure C programming to many of the C programming chapters. Weve also posted a Secure C Programming Resource Center at www.deitel.comSecureC. For more details, see the section A Note About Secure C Programming in this Preface.
? Focus on Performance Issues. C and C are favored by designers of performance-intensive applications such as operating systems, real-time systems, embedded systems and communications systems, so we focus intensively on performance issues.
? Making a Difference Exercise Sets. We encourage you to use computers and the Internet to research and solve problems that really matter. These exercises are meant to increase awareness of important issues the world is facing. We hope youll approach them with your own values, politics and beliefs.
? All Code Tested on Windows and Linux. Weve tested every example and exercise program using Visual C and GNU gcc in Windows and Linux, respectively.
? Updated Coverage of C and Object-Oriented Programming. We updated