Modern C for Absolute Beginners: A Friendly Introduction to the C Programming Language / Современный Си для абсолютных новичков: Дружественное введение в язык программирования Си
Год издания: 2021
Автор: Dmitrović Slobodan / Дмитрович Слободан
Издательство: Apress Media
ISBN: 978-1-4842-6643-4
Язык: Английский
Формат: PDF, EPUB
Качество: Издательский макет или текст (eBook)
Интерактивное оглавление: Да
Количество страниц: 338
Описание: Learn the C programming language easily and in a straightforward way. This book teaches the basics of C, the C Standard Library, and modern C standards. No previous programming experience is required.
C is a language that is as popular today as it was decades ago. C covers a wide variety of domains. It can be used to program a microcontroller, or to develop an entire operating system. This book is an effort to introduce the reader to the C programming language in a concise and easy to follow manner.
The author takes you through the C programming language, the Standard Library, and the C standards basics. Each chapter is the right balance of theory and code examples.
After reading and using this book, you'll have the essentials to start programming in modern C.
What You Will Learn
The C programming language fundamentals
The C Standard Library fundamentals
New C Standards features
The basics of types, operators, statements, arrays, functions, and structs
The basics of pointers, memory allocation, and memory manipulation
Take advantage of best practices in C
Who This Book Is For
Beginner or novice programmers who wish to learn the C programming language. No prior programming experience is required.
Изучайте язык программирования Си легко и понятным способом. Эта книга знакомит с основами языка Си, стандартной библиотекой Си и современными стандартами Си. Предыдущий опыт программирования не требуется.
Си - это язык, который сегодня так же популярен, как и десятилетия назад. Язык Си охватывает широкий спектр областей. Его можно использовать для программирования микроконтроллера или для разработки целой операционной системы. Эта книга представляет собой попытку познакомить читателя с языком программирования Си в сжатой и простой для понимания форме.
Автор знакомит вас с языком программирования Си, стандартной библиотекой и основами стандартов Си. Каждая глава представляет собой правильный баланс теории и примеров кода.
После прочтения и использования этой книги у вас будет все необходимое для начала программирования на современном Си.
Что Вы узнаете
Основы языка программирования Си
Основы стандартной библиотеки Си
Новые возможности стандартов Си
Основы типов, операторов, инструкций, массивов, функций и структур
Основы указателей, выделения памяти и манипулирования памятью
Воспользуйтесь лучшими практиками в C
Для кого предназначена эта книга
Начинающие программисты, желающие изучить язык программирования Си. Предварительный опыт программирования не требуется.
Оглавление
About the Author xv
About the Technical Reviewer xvii
Acknowledgments xix
Chapter 4: Exercises 31
4.1 Hello World with Comments 31
4.1.1 Declaration 32
4.1.2 Definition 32
4.1.3 Outputting Values 32
Chapter 5: Operators 35
5.1 Introduction 35
5.2 Arithmetic Operators 35
5.3 Assignment Operator 36
5.4 Compound Assignment Operators 38
5.5 Relational Operators 38
5.6 Equality Operators 39
5.7 Logical Operators 40
5.8 Increment and Decrement Operators 41
5.9 O perator Precedence 43
Chapter 6: Expressions 45
6.1 Initialization 45
6.2 Type Conversion 46
Chapter 7: Statements 49
7.1 Introduction 49
7.2 Selection Statements 51
7.2.1 if 51
7.2.2 if-else 54
7.2.3 switch 57
7.3 Iteration Statements 61
7.3.1 while 61
7.3.2 do-while 62
7.3.3 for 63
Chapter 8: Exercises 67
8.1 Arithmetic Operations 67
8.2 Integral Division 67
8.3 Floating-Point Division and Casting 68
8.4 Equality Operator 68
8.5 Relational and Logical Operators 69
8.6 The switch Statement 70
8.7 Iteration Statements 71
Chapter 9: Arrays 73
9.1 Declaration 73
9.2 Subscript Operator 74
9.3 Array Initialization 76
9.4 Character Arrays 78
9.5 Multidimensional Arrays 79
9.6 Array Size and Count 80
Chapter 10: Pointers 83
10.1 Introduction 83
10.2 Declaration and Initialization 83
10.3 Pointers and Arrays 86
10.4 Pointer Arithmetics 89
10.5 V oid Pointers 91
10.6 Pointer to Character Arrays 93
10.7 Arrays of Pointers 94
Chapter 11: Command-Line Arguments 97
Chapter 12: Exercises 99
12.1 Character Array 99
12.2 Array Elements 99
12.3 Pointer to an Existing Object 100
12.4 Pointers and Arrays 101
12.5 Pointer to a Character Array 101
12.6 Pointer Arithmetics 102
12.7 Array of Pointers 102
Chapter 13: Functions 105
13.1 Introduction 105
13.2 Function Declaration 107
13.3 Function Definition 109
13.4 Parameters and Arguments 111
13.4.1 Passing Arguments 114
13.5 Return Statement 116
Chapter 14: Exercises 119
14.1 A Simple Function 119
14.2 Function Declaration and Definition 119
14.3 Passing Arguments by Value 120
14.4 Passing Arguments by Pointer/Address 121
14.5 Function – Multiple Parameters 121
Chapter 15: Structures 123
15.1 Introduction 123
15.2 Initialization 126
15.3 Member Access Operator 128
15.4 Copying Structures 130
15.5 Pointers to Structures 131
15.6 Self-Referencing Structures 133
15.7 Structures as Function Arguments 134
Chapter 16: Unions 139
Chapter 17: Conditional Expression 141
Chapter 18: Typedef 143
Chapter 19: Const Qualifier 147
Chapter 20: Enumerations 153
Chapter 21: Function Pointers 157
Chapter 22: Exercises 161
22.1 Structure Definition 161
22.2 Structure Typedef Alias 162
22.3 Structure Initialization 163
22.4 Pointers to Structures 164
22.5 Unions 165
22.6 Const Variables and Pointers 165
22.7 Constant Function Parameters 166
22.8 Enums 167
22.9 Pointers to Functions 168
Chapter 23: Preprocessor 171
23.1 #include 171
23.2 #define 173
23.3 #undef 175
23.4 Conditional Compilation 176
23.4.1 #if 177
23.4.2 #ifdef 178
23.4.3 #ifndef 180
23.5 Built-in Macros 181
23.6 Function-Like Macros 182
Chapter 24: Exercises 185
24.1 Define and Undefine a Macro 185
24.2 Conditional Compilation 186
24.3 Built-in Macros 186
24.4 Function Macros 187
Chapter 25: Dynamic Memory Allocation 189
25.1 malloc 190
25.2 calloc 198
25.3 realloc 200
Chapter 26: Storage and Scope 203
26.1 Scope 203
26.1.1 Local Scope 203
26.1.2 Global Scope 204
26.2 Storage 206
26.2.1 Automatic Storage Duration 206
26.2.2 Static Storage Duration 207
26.2.3 Allocated Storage Duration 208
Chapter 27: Exercises 211
27.1 Dynamic Memory Allocation 211
27.2 Dynamic Memory Allocation: Arrays 212
27.3 Dynamic Memory Resizing 213
27.4 Automatic and Allocated Storage 214
Chapter 28: Standard Input and Output 215
28.1 Standard Input 215
28.1.1 scanf 215
28.1.2 sscanf 217
28.1.3 fgets 218
28.2 Standard Output 220
28.2.1 printf 220
28.2.2 puts 222
28.2.3 fputs 222
28.2.4 putchar 223
Chapter 29: File Input and Output 225
29.1 File Input 225
29.2 File Output 227
Chapter 30: Exercises 229
30.1 Standard Input 229
30.2 Standard Output 230
Chapter 31: Header and Source Files 233
Part II: The C Standard Library 237
Chapter 32: Introduction to C Standard Library 239
32.1 String Manipulation 240
32.1.1 strlen 241
32.1.2 strcmp 242
32.1.3 strcat 243
32.1.4 strcpy 243
32.1.5 strstr 244
32.2 Memory Manipulation Functions 245
32.2.1 memset 246
32.2.2 memcpy 247
32.2.3 memcmp 249
32.2.4 memchr 251
32.3 Mathematical Functions 251
32.3.1 abs 252
32.3.2 fabs 252
32.3.3 pow 253
32.3.4 round 253
32.3.5 s qrt 255
32.4 S tring Conversion Functions 255
32.4.1 strtol 255
32.4.2 snprintf 257
Part III: Modern C Standards 259
Chapter 33: Introduction to C11 Standard 261
33.1 Static_assert 261
33.2 The _Noreturn Function Specifier 262
33.3 Type Generic Macros Using _Generic 263
33.4 The _Alignof Operator 266
33.5 The _Alignas Specifier 267
33.6 Anonymous Structures and Unions 268
33.7 Aligned Memory Allocation: aligned_alloc 269
33.8 Unicode Support for UTF-16 and UTF-32 270
33.9 Bounds Checking and Threads Overview 270
33.9.1 Bounds-Checking Functions 270
33.9.2 Threads Support 271
Chapter 34: The C17 Standard 273
Chapter 35: The Upcoming C2X Standard 275
35.1 Static_assert Without a Message 275
35.2 Attributes 276
35.3 No Parameters Function Declaration 277
35.4 The strdup Function 277
35.5 The memccpy Function 279
Part IV: Dos and Don’ts 281
Chapter 36: Do Not Use the gets Function 283
Chapter 37: Initialize Variables Before Using Them 285
Chapter 38: Do Not Read Out of Bounds 287
Chapter 39: Do Not Free the Allocated Memory Twice 289
Chapter 40: Do Not Cast the Result of malloc 291
Chapter 41: Do Not Overflow a Signed Integer 293
Chapter 42: Cast a Pointer to void* When Printing Through printf 295
Chapter 43: Do Not Divide by Zero 297
Chapter 44: Where to Use Pointers? 299
44.1 Pointers to Existing Objects 299
44.2 Pointers to Arrays 300
44.3 Pointers to String Constants 302
44.4 Pointers to Dynamically Allocated Memory 303
44.5 Pointers as Function Arguments 304
Chapter 45: Prefer Functions to Function-Like Macros 307
Chapter 46: static Global Names 309
Chapter 47: What to Put in Header Files? 311
47.1 Shared Macros 311
47.2 Function Declarations 313
47.3 Shared extern Variables and Constants 314
47.4 Other Header Files 316
Part V: Appendices 317
Appendix A: Linkage 319
Appendix B: Time and Date 321
Appendix C: Bitwise Operators 325
C.1 The Bitwise NOT Operator ~ 325
C.2 Bitwise Shift Operators << and >> 327
C.3 The Bitwise AND Operator & 330
Appendix D: Numeric Limits 333
D .1 Integer Types Limits 333
D.2 Floating-Point Types Limits 335
Appendix E: Summary and Advice 337
E.1 What to Learn Next? 337
E.2 Online References 338
E.3 Other C Books 338
E.4 Advice 338
Index 341
Dmitrović Slobodan / Дмитрович Слободан - Modern C for Absolute Beginners, 2nd Edition / Современный C для начинающих, 2-е издание [2024, PDF/EPUB, ENG]