True pdf. Final release. ISBN-13: 978-1718501041. August 11th 2020. ------------------------- A detailed introduction to the C programming language for experienced programmers. The world runs on code written in the C programming language, yet most schools begin the curriculum with Python or Java. Effective C bridges this gap and brings C into the modern era--covering the modern C17 Standard as well as potential C2x features. With the aid of this instant classic, you'll soon be writing professional, portable, and secure C programs to power robust systems and solve real-world problems. Robert C. Seacord introduces C and the C Standard Library while addressing best practices, common errors, and open debates in the C community. Developed together with other C Standards committee experts, Effective C will teach you how to debug, test, and analyze C programs. You'll benefit from Seacord's concise explanations of C language constructs and behaviors, and from his 40 years of coding experience. You'll learn: • How to identify and handle undefined behavior in a C program • The range and representations of integers and floating-point values • How dynamic memory allocation works and how to use nonstandard functions • How to use character encodings and types • How to perform I/O with terminals and filesystems using C Standard streams and POSIX file descriptors • How to understand the C compiler's translation phases and the role of the preprocessor • How to test, debug, and analyze C programs Effective C will teach you how to write professional, secure, and portable C code that will stand the test of time and help strengthen the foundation of the computing world. ------------------------- Effective C: An Introduction to Professional C Programming is a concise introduction to essential C language programming that will have you writing programs, solving problems, and building working systems in no time. In this book, you’ll learn about essential programming concepts in C and practice writing high quality code with exercises for each topic. You’ll also learn about good software engineering practices for developing correct, secure C code. ---------------------------------------- Robert C. Seacord is a Technical Director with NCC Group where he works with software developers and software development organizations to eliminate vulnerabilities resulting from coding errors before they are deployed. Previously, Robert founded and led the secure coding initiative in the CERT Division of Carnegie Mellon University’s Software Engineering Institute (SEI). Robert is also an adjunct professor in the School of Computer Science and the Information Networking Institute at Carnegie Mellon University. Robert is the author of six other books, including “The CERT C Coding Standard, Second Edition” (Addison-Wesley, 2014), “Secure Coding in C and C++, Second Edition” (Addison-Wesley, 2013), and “Java Coding Guidelines: 75 Recommendations for Reliable and Secure Programs” (Addison-Wesley, 2014). Robert is on the Advisory Board for the Linux Foundation and an expert on the ISO/IEC JTC1/SC22/WG14 international standardization working group for the C programming language. ------------------------------------------ Brief Contents 11 Contents in Detail 13 Foreword by Pascal Cuoq 19 Foreword by Ollie Whitehouse 21 Acknowledgments 23 Introduction 25 A Brief History of C 26 The C Standard 27 The CERT C Coding Standard 28 Who This Book Is For 28 What’s in This Book 28 Chapter 1: Getting Started with C 31 Developing Your First C Program 31 Compiling and Running Your Program 32 Preprocessor Directives 33 The main Function 33 Checking Function Return Values 35 Formatted Output 35 Editors and Integrated Development Environments 36 Compilers 38 GNU Compiler Collection 38 Clang 38 Microsoft Visual Studio 39 Portability 39 Implementation-Defined Behavior 40 Unspecified Behavior 40 Undefined Behavior 40 Locale-Specific Behavior and Common Extensions 41 Summary 41 Chapter 2: Objects, Functions, and Types 43 Objects, Functions, Types, and Pointers 43 Declaring Variables 44 Swapping Values (First Attempt) 45 Swapping Values (Second Attempt) 46 Scope 48 Storage Duration 49 Alignment 50 Object Types 51 Boolean Types 51 Character Types 52 Numerical Types 52 void Types 54 Function Types 54 Derived Types 55 Pointer Types 55 Arrays 56 Structures 58 Unions 59 Tags 60 Type Qualifiers 62 const 62 volatile 63 restrict 63 Exercises 64 Summary 64 Chapter 3: Arithmetic Types 65 Integers 66 Padding and Precision 66 The Header File 66 Declaring Integers 67 Unsigned Integers 67 Signed Integers 70 Integer Constants 74 Floating-Point 75 Floating-Point Types 76 Floating-Point Arithmetic 77 Floating-Point Values 77 Floating-Point Constants 79 Arithmetic Conversion 79 Integer Conversion Rank 80 Integer Promotions 81 Usual Arithmetic Conversions 82 An Example of Implicit Conversion 83 Safe Conversions 84 Summary 85 Chapter 4: Expressions and Operators 87 Simple Assignment 88 Evaluations 89 Function Invocation 90 Increment and Decrement Operators 91 Operator Precedence and Associativity 92 Order of Evaluation 94 Unsequenced and Indeterminately Sequenced Evaluations 95 Sequence Points 96 sizeof Operator 96 Arithmetic Operators 97 Unary + and – Operators 97 Logical Negation Operator 98 Multiplicative Operators 98 Additive Operators 99 Bitwise Operators 99 Complement Operator 100 Shift Operators 100 Bitwise AND Operator 102 Bitwise Exclusive OR Operator 102 Bitwise Inclusive OR Operator 103 Logical Operators 103 Cast Operators 105 Conditional Operator 106 _Alignof Operator 106 Relational Operators 107 Compound Assignment Operators 108 Comma Operator 108 Pointer Arithmetic 109 Summary 110 Chapter 5: Control Flow 111 Expression Statements 111 Compound Statements 112 Selection Statements 113 The if Statement 113 The switch Statement 116 Iteration Statements 119 The while Statement 119 The do...while Statement 120 The for Statement 121 Jump Statements 123 The goto Statement 123 The continue Statement 124 The break Statement 125 The return Statement 126 Exercises 127 Summary 127 Chapter 6: Dynamically Allocated Memory 129 Storage Duration 130 The Heap and Memory Managers 130 When to Use Dynamically Allocated Memory 131 Memory Management Functions 131 The malloc Function 132 The aligned_alloc Function 134 The calloc Function 135 The realloc Function 135 The reallocarray Function 137 The free Function 138 Memory States 139 Flexible Array Members 140 Other Dynamically Allocated Storage 141 The alloca Function 141 Variable-Length Arrays 142 Debugging Allocated Storage Problems 145 Dmalloc 146 Safety-Critical Systems 148 Exercises 148 Summary 148 Chapter 7: Characters and Strings 149 Characters 150 ASCII 150 Unicode 150 Source and Execution Character Sets 152 Data Types 152 Character Constants 154 Escape Sequences 155 Linux 156 Windows 156 Character Conversion 158 Strings 161 String Literals 162 String-Handling Functions 164 and 165 Annex K Bounds-Checking Interfaces 171 POSIX 174 Microsoft 175 Summary 175 Chapter 8: Input/Output 177 Standard I/O Streams 178 Stream Buffering 178 Predefined Streams 179 Stream Orientation 180 Text and Binary Streams 180 Opening and Creating Files 181 The fopen Function 181 The POSIX open Function 183 Closing Files 184 The fclose Function 184 The POSIX close Function 185 Reading and Writing Characters and Lines 185 Stream Flushing 187 Setting the Position in a File 188 Removing and Renaming Files 191 Using Temporary Files 191 Reading Formatted Text Streams 192 Reading to and Writing from Binary Streams 195 Summary 198 Chapter 9: Preprocessor 199 The Compilation Process 200 File Inclusion 201 Quoted and Angle Bracket Include Strings 202 Conditional Inclusion 202 Generating Errors 203 Using Header Guards 204 Macro Definitions 205 Macro Replacement 208 Type-Generic Macros 210 Predefined Macros 211 Summary 213 Chapter 10: Program Structure 215 Principles of Componentization 216 Coupling and Cohesion 216 Code Reuse 217 Data Abstractions 217 Opaque Types 218 Executables 219 Linkage 221 Structuring a Simple Program 222 Building the Code 226 Summary 228 Chapter 11: Debugging, Testing, and Analysis 229 Assertions 229 Static Assertions 230 Runtime Assertions 232 Compiler Settings and Flags 233 GCC and Clang 234 Visual C++ 236 Debugging 238 Unit Testing 241 Static Analysis 244 Dynamic Analysis 246 AddressSanitizer 247 Exercises 251 Summary 251 References 253 Index 257 A Detailed Introduction To The C Programming Language For Experienced Programmers. The World Runs On Code Written In The C Programming Language, But Most Computer Science Programs Only Teach Java Or Python As An Introductory Language. This Book Is For Developers Who Already Know How To Program And Want To Quickly Come Up To Speed On Professional Programming In C. They'll Learn How To Develop Correct, Portable, Professional-quality Code And Build A Foundation For Developing Security-critical And Safety-critical Systems. Written By Renowned Author Robert Seacord, C As A Second Language Is An In-depth Look At The C Programming Language. Seacord Introduces The Language's Basic Data Types And Code Structures While Simultaneously Addressing Best Practices, Common Errors, And Open Debates In The C Community. Readers Will Also Learn How To Debug, Test, And Analyze C Programs And Benefit From Detailed Yet Concise Explanations Of C Language Constructs And Behaviors Readers Will Learn: * How To Identify And Handle Undefined Behavior In A C Program * The Range And Representations Of Integers And Floating-point Values * How Integer Promotions Are Performed And How They May Affect Portability * The Order Of Evaluation Of Expressions * Dynamic Memory Allocation Including The Use Of Non-standard Functions * The Philosophy Underlying The Use Of Character Types In C * Character Encodings And Types * How To Perform Input/output (i/o) With Terminals And File Systems Using C Standard Streams And Posix File Descriptors * The Translation Phases Implemented By The C Compiler And The Role Of The Preprocessor * Testing, Debugging, And Analyzing C Programs Developed In Collaboration With C Standard Committee Experts, C As A Second Language Will Teach Developers How To Write Correct, Portable, Professional-quality C Code. "An in-depth guide for developers who already know how to program and want to quickly come up to speed on professional programming in C. It introduces the language's basic data types and code structures ; addresses best practices and common errors ; and teaches how to debug, test, and analyze C programs"--Provided by publisher "An in-depth guide for developers who already know how to program and want to quickly come up to speed on professional programming in C. It introduces the language's basic data types and code structures ; addresses best practices and common errors ; and teaches how to debug, test, and analyze C programs" Provided by publisher