The professional programmer's Deitel (R) guide to procedural programming in C through 130 working code examples Written for programmers with a background in high-level language programming, this book applies the Deitel signature live-code approach to teaching the C language and the C Standard Library. The book presents the concepts in the context of fully tested programs, complete with syntax shading, code highlighting, code walkthroughs and program outputs. The book features approximately 5,000 lines of proven C code and hundreds of savvy tips that will help you build robust applications. Start with an introduction to C, then rapidly move on to more advanced topics, including building custom data structures, the Standard Library, select features of the new C11 standard such as multithreading to help you write high-performance applications for today's multicore systems, and secure C programming sections that show you how to write software that is more robust and less vulnerable. You'll enjoy the Deitels' classic treatment of procedural programming. When you're finished, you'll have everything you need to start building industrial-strength C applications. Practical, example-rich coverage of: C programming fundamentals Compiling and debugging with GNU gcc and gdb, and Visual C++ (R) Key new C11 standard features: Type generic expressions, anonymous structures and unions, memory alignment, enhanced Unicode (R) support, _Static_assert, quick_exit and at_quick_exit, _Noreturn function specifier, C11 headers C11 multithreading for enhanced performance on today's multicore systems Secure C Programming sections Data structures, searching and sorting Order of evaluation issues, preprocessor Designated initializers, compound literals, bool type, complex numbers, variable-length arrays, restricted pointers, type generic math, inline functions, and more. Visit www.deitel.com For information on Deitel's Dive Into (R) Series programming training courses delivered at organizations worldwide visit www.deitel.com/training or write to deitel@deitel.com Download code examples To receive updates for this book, subscribe to the free DEITEL (R) BUZZ ONLINE e-mail newsletter at www.deitel.com/newsletter/subscribe.html Join the Deitel social networking communities on Facebook (R) at facebook.com/DeitelFan, Twitter (R) @deitel, LinkedIn (R) at bit.ly/DeitelLinkedIn and Google+ (TM) at gplus.to/Deitel
Les mer
Preface xv Chapter 1: Introduction 1 1.1 Introduction 2 1.2 The C Programming Language 2 1.3 CStandard Library 4 1.4 C++ and Other C-Based Languages 4 1.5 Typical C Program Development Environment 5 1.6 Test-Driving a C Application in Windows, Linux and Mac OS X 8 1.7 Operating Systems 16 Chapter 2: Introduction to C Programming 19 2.1 Introduction 20 2.2 ASimple C Program: Printing a Line of Text 20 2.3 Another Simple C Program: Adding Two Integers 24 2.4 Arithmetic in C 27 2.5 Decision Making: Equality and Relational Operators 31 2.6 Secure C Programming 35 Chapter 3: Control Statements: Part I 37 3.1 Introduction 38 3.2 Control Structures 38 3.3 The if Selection Statement 40 3.4 The if...else Selection Statement 40 3.5 The while Repetition Statement 43 3.6 Class Average with Counter-Controlled Repetition 44 3.7 Class Average with Sentinel-Controlled Repetition 46 3.8 Nested Control Statements 49 3.9 Assignment Operators 51 3.10 Increment and Decrement Operators 52 3.11 Secure C Programming 55 Chapter 4: Control Statements: Part II 57 4.1 Introduction 58 4.2 Repetition Essentials 58 4.3 Counter-Controlled Repetition 59 4.4 for Repetition Statement 60 4.5 for Statement: Notes and Observations 63 4.6 Examples Using the for Statement 64 4.7 switch Multiple-Selection Statement 67 4.8 do...while Repetition Statement 73 4.9 break and continue Statements 75 4.10 Logical Operators 77 4.11 Confusing Equality (==) and Assignment (=) Operators 80 4.12 Secure C Programming 81 Chapter 5: Functions 83 5.1 Introduction 84 5.2 Program Modules in C 84 5.3 Math Library Functions 85 5.4 Functions 86 5.5 Function Definitions 87 5.6 Function Prototypes: A Deeper Look 91 5.7 Function Call Stack and Stack Frames 94 5.8 Headers 97 5.9 Passing Arguments By Value and By Reference 98 5.10 Random Number Generation 99 5.11 Example: A Game of Chance 104 5.12 Storage Classes 107 5.13 Scope Rules 109 5.14 Recursion 112 5.15 Example Using Recursion: Fibonacci Series 116 5.16 Recursion vs. Iteration 119 5.17 Secure C Programming 121 Chapter 6: Arrays 122 6.1 Introduction 123 6.2 Arrays 123 6.3 Defining Arrays 124 6.4 Array Examples 125 6.5 Passing Arrays to Functions 138 6.6 Sorting Arrays 142 6.7 Case Study: Computing Mean, Median and Mode Using Arrays 144 6.8 Searching Arrays 149 6.9 Multidimensional Arrays 155 6.10 Variable-Length Arrays 162 6.11 Secure C Programming 165 Chapter 7: Pointers 167 7.1 Introduction 168 7.2 Pointer Variable Definitions and Initialization 168 7.3 Pointer Operators 169 7.4 Passing Arguments to Functions by Reference 172 7.5 Using the const Qualifier with Pointers 176 7.6 Bubble Sort Using Pass-by-Reference 182 7.7 sizeof Operator 185 7.8 Pointer Expressions and Pointer Arithmetic 188 7.9 Relationship between Pointers and Arrays 190 7.10 Arrays of Pointers 194 7.11 Case Study: Card Shuffling and Dealing Simulation 195 7.12 Pointers to Functions 199 7.13 Secure C Programming 204 Chapter 8: Characters and Strings 205 8.1 Introduction 206 8.2 Fundamentals of Strings and Characters 206 8.3 Character-Handling Library 208 8.4 String-Conversion Functions 213 8.5 Standard Input/Output Library Functions 217 8.6 String-Manipulation Functions of the String-Handling Library 221 8.7 Comparison Functions of the String-Handling Library 224 8.8 Search Functions of the String-Handling Library 225 8.9 Memory Functions of the String-Handling Library 231 8.10 Other Functions of the String-Handling Library 236 8.11 Secure C Programming 237 Chapter 9: Formatted Input/Output 238 9.1 Introduction 239 9.2 Streams 239 9.3 Formatting Output with printf 239 9.4 Printing Integers 240 9.5 Printing Floating-Point Numbers 241 9.6 Printing Strings and Characters 243 9.7 Other Conversion Specifiers 244 9.8 Printing with Field Widths and Precision 245 9.9 Using Flags in the printf Format Control String 247 9.10 Printing Literals and Escape Sequences 250 9.11 Reading Formatted Input with scanf 251 9.12 Secure C Programming 257 Chapter 10: Structures, Unions, Bit Manipulation and Enumerations 258 10.1 Introduction 259 10.2 Structure Definitions 259 10.3 Initializing Structures 262 10.4 Accessing Structure Members 262 10.5 Using Structures with Functions 264 10.6 typedef 264 10.7 Example: High-Performance Card Shuffling and Dealing Simulation 265 10.8 Unions 268 10.9 Bitwise Operators 270 10.10 Bit Fields 279 10.11 Enumeration Constants 282 10.12 Secure C Programming 284 Chapter 11: File Processing 285 11.1 Introduction 286 11.2 Files and Streams 286 11.3 Creating a Sequential-Access File 287 11.4 Reading Data from a Sequential-Access File 292 11.5 Random-Access Files 296 11.6 Creating a Random-Access File 297 11.7 Writing Data Randomly to a Random-Access File 299 11.8 Reading Data from a Random-Access File 302 11.9 Case Study: Transaction-Processing Program 303 11.10 Secure C Programming 309 Chapter 12: Data Structures 311 12.1 Introduction 312 12.2 Self-Referential Structures 312 12.3 Dynamic Memory Allocation 313 12.4 Linked Lists 314 12.5 Stacks 323 12.6 Queues 329 12.7 Trees 335 12.8 Secure C Programming 340 Chapter 13: Preprocessor 342 13.1 Introduction 343 13.2 #include Preprocessor Directive 343 13.3 #define Preprocessor Directive: Symbolic Constants 344 13.4 #define Preprocessor Directive: Macros 344 13.5 Conditional Compilation 346 13.6 #error and #pragma Preprocessor Directives 347 13.7 # and ## Operators 348 13.8 Line Numbers 348 13.9 Predefined Symbolic Constants 348 13.10 Assertions 349 13.11 Secure C Programming 349 Chapter 14: Other Topics 351 14.1 Introduction 352 14.2 Redirecting I/O 352 14.3 Variable-Length Argument Lists 353 14.4 Using Command-Line Arguments 355 14.5 Notes on Compiling Multiple-Source-File Programs 356 14.6 Program Termination with exit and atexit 358 14.7 Suffixes for Integer and Floating-Point Literals 359 14.8 Signal Handling 360 14.9 Dynamic Memory Allocation: Functions calloc and realloc 362 14.10 Unconditional Branching with goto 363 Appendix A: Operator Precedence Chart 365 Appendix B: ASCII Character Set 367 Appendix C: Number Systems 368 C.1 Introduction 369 C.2 Abbreviating Binary Numbers as Octal and Hexadecimal Numbers 372 C.3 Converting Octal and Hexadecimal Numbers to Binary Numbers 373 C.4 Converting from Binary, Octal or Hexadecimal to Decimal 373 C.5 Converting from Decimal to Binary, Octal or Hexadecimal 374 C.6 Negative Binary Numbers: Two's Complement Notation 376 Appendix D: Sorting: A Deeper Look 378 D.1 Introduction 379 D.2 Big O Notation 379 D.3 Selection Sort 380 D.4 Insertion Sort 384 D.5 Merge Sort 387 Appendix E: Additional Features of the C Standard 394 E.1 Introduction 395 E.2 Support for C99 396 E.3 C99 Headers 396 E.4 Mixing Declarations and Executable Code 397 E.5 Declaring a Variable in a for Statement Header 397 E.6 Designated Initializers and Compound Literals 398 E.7 Type bool 401 E.8 Implicit int in Function Declarations 402 E.9 Complex Numbers 403 E.10 Variable-Length Arrays 404 E.11 Additions to the Preprocessor 407 E.12 Other C99 Features 408 E.13 New Features in the C11 Standard 411 E.14 Web Resources 422 Appendix F: Using the Visual Studio Debugger 425 F.1 Introduction 426 F.2 Breakpoints and the Continue Command 426 F.3 Locals and Watch Windows 430 F.4 Controlling Execution Using the Step Into, Step Over, Step Out and Continue Commands 432 F.5 Autos Window 434 Appendix G: Using the GNU Debugger 436 G.1 Introduction 437 G.2 Breakpoints and the run, stop, continue and print Commands 437 G.3 print and set Commands 442 G.4 Controlling Execution Using the step, finish and next Commands 444 G.5 watch Command 446 Index 449
Les mer
Comments from Recent Editions' Reviewers "While C is a complex language, this book does a good job making this material accessible while providing a strong foundation for further learning." -Robert C. Seacord, Secure Coding Manager at SEI/CERT, author of The CERT C Secure Coding Standard and technical expert for the working group responsible for the C Programming Language Standard "An excellent introduction to the C programming language, with many clear examples. Pitfalls of the C language are clearly identified and concise programming methods are defined to avoid them." -John Benito, Blue Pilot Consulting, Inc., and Convener of ISO WG14-the working group responsible for the C Programming Language Standard "A great introduction to the C programming language and software engineering. It's fresh and up to date with modern software industry realities." -Vytautus Leonavicius, Microsoft "An impressive job explaining a topic as complex as pointers in such an easy-to-understand way. The discussions of secure C programming are valuable." -Jose Antonio Gonzalez Seco, Parliament of Andalusia, Spain "The extended examples, along with the supporting text, are the best of any of the C books I've seen. Running the code for the supplied examples in conjunction with reading the text provides readers with a laboratory for gaining a thorough understanding of how C works." -Tom Rethard, University of Texas at Arlington "Introduces C programming and gets you ready for the job market, with best practices and development tips to help you become an able and employable candidate. Nice multi-platform explanation." -Hemanth H.M., Software Engineer at SonicWALL "This book is an invaluable resource for both beginning and seasoned programmers. The authors' approach to explaining concepts, techniques and practices is comprehensive, engaging and easy to understand. This is a must-have book." -Bin Wang, Department of Computer Science and Engineering, Wright State University "Continues a tradition of excellence in Deitel texts. It presents C clearly and accurately with a well-organized exposition which builds from simple concepts to ultimately describing the complete language, making the book valuable for experienced programmers. This is an exceptional reference for the C programmer." -Roy Seyfarth, University of Southern Mississippi "One of the best C programming books on the market. The live-code approach makes it easy to understand the basics of C programming. I highly recommend this book as both a teaching text and a reference." -Xiaolong Li, Indiana State University "I have been teaching introductory programming courses since 1975, and programming in the C language since 1986. In the beginning there were no good textbooks on C-in fact, there weren't any! When Deitel, C How to Program, 1/e [the textbook first version of this book], came out, we jumped on it-it was at the time clearly the best text on C. The new edition continues a tradition-it's by far the best student-oriented textbook on programming in the C language-the Deitels have set the standard-again! A thorough, careful, student-oriented treatment of not just the language, but more importantly, the ideas, concepts and techniques of programming! 'Live code' is also a big plus, encouraging active participation by the reader. A great book!" -Richard Albright, Goldey-Beacom College "I like the quality of the writing; it's polished, well-structured, touches important topics and outlines common mistakes really well. Nice visualization of binary search. The card shuffling example illustrates a solution to the problem with great coding and explanation. Nice example on signal handling." -Vytautus Leonavicius, Microsoft "The control statements chapters are excellent. Great coverage of functions. The strings and characters discussion is easy to follow. The writing in the 'Structures, Unions, Bit Manipulation and Enumerations' chapter is very clear. The 'Data Structures' chapter is well written and the examples are great. The 'Other Topics' chapter does a good job closing the coverage of the C language with all those 'little things.'" -Jose Antonio Gonzalez Seco, Parliament of Andalusia, Spain "Clearly demonstrates important C programming concepts. The introductory chapters are very good. The examples in the 'Functions' chapter were good. Just the right amount of coverage of arrays. The C Pointers chapter is well-written; the coverage is quite detailed. Excellent discussion of many of the string functions. Fine chapters on formatted input/output and files. Good introduction to data structures. I was pleased to see a hint at Big O running time in the binary search example. Good information in the preprocessor chapter." -Dr. John F. Doyle, Indiana University Southeast "The Deitel book easily provides the clearest and most in-depth approach to standard C programming. With the Deitel C book, readers have a tremendous resource that will enable them to succeed in the professional workplace for years to come." -William Smith, Tulsa Community College "Covers material that will be useful the job market." -Fred J. Tydeman, Tydeman Consulting, Vice-Chair of J11 (ANSI C)
Les mer

Produktdetaljer

ISBN
9780133462067
Publisert
2013-05-02
Utgiver
Vendor
Prentice Hall
Vekt
752 gr
Høyde
180 mm
Bredde
230 mm
Dybde
26 mm
Aldersnivå
05, U
Språk
Product language
Engelsk
Format
Product format
Heftet
Antall sider
608

Biographical note

Paul Deitel and Harvey Deitel are the founders of Deitel & Associates, Inc., the internationally recognized programming languages authoring and corporate-training organization. Millions of people worldwide have used Deitel books, e-books, LiveLessons videos, e-articles and online resource centers to master C, C++, Visual C++ (R), Java (TM), C#, Visual Basic (R), Android (TM) app development, iOS (R) app development, Internet and web programming, HTML5, JavaScript (R), CSS3, XML, Perl, Python (R) and more.