Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learn C Programming

You're reading from   Learn C Programming A beginner's guide to learning the most powerful and general-purpose programming language with ease

Arrow left icon
Product type Paperback
Published in Aug 2022
Publisher Packt
ISBN-13 9781801078450
Length 742 pages
Edition 2nd Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Jeff Szuhay Jeff Szuhay
Author Profile Icon Jeff Szuhay
Jeff Szuhay
Arrow right icon
View More author details
Toc

Table of Contents (38) Chapters Close

Preface 1. Part 1: C Fundamentals
2. Chapter 1: Running Hello, World! FREE CHAPTER 3. Chapter 2: Understanding Program Structure 4. Chapter 3: Working with Basic Data Types 5. Chapter 4: Using Variables and Assignments 6. Chapter 5: Exploring Operators and Expressions 7. Chapter 6: Exploring Conditional Program Flow 8. Chapter 7: Exploring Loops and Iterations 9. Chapter 8: Creating and Using Enumerations 10. Part 2: Complex Data Types
11. Chapter 9: Creating and Using Structures 12. Chapter 10: Creating Custom Data Types with typedef 13. Chapter 11: Working with Arrays 14. Chapter 12: Working with Multi-Dimensional Arrays 15. Chapter 13: Using Pointers 16. Chapter 14: Understanding Arrays and Pointers 17. Chapter 15: Working with Strings 18. Chapter 16: Creating and Using More Complex Structures 19. Part 3: Memory Manipulation
20. Chapter 17: Understanding Memory Allocation and Lifetime 21. Chapter 18: Using Dynamic Memory Allocation 22. Part 4: Input and Output
23. Chapter 19: Exploring Formatted Output 24. Chapter 20: Getting Input from the Command Line 25. Chapter 21: Exploring Formatted Input 26. Chapter 22: Working with Files 27. Chapter 23: Using File Input and File Output 28. Part 5: Building Blocks for Larger Programs
29. Chapter 24: Working with Multi-File Programs 30. Chapter 25: Understanding Scope 31. Chapter 26: Building Multi-File Programs with Make 32. Chapter 27: Creating Two Card Programs 33. Epilogue 34. Assessments 35. Index 36. Other Books You May Enjoy Appendix

What this book covers

Part 1, C Fundamentals, introduces the very basic concepts of C syntax and program structure.

Chapter 1, Running Hello, World!, introduces the program development cycle and the tools you'll need for the rest of the book. Those tools are used to create, build, and run your first C program, a "Hello, world!" program. The concepts of commenting code and experimenting with code are also introduced.

Chapter 2, Understanding Program Structure, introduces statements and blocks. It also describes function definitions and function declarations, also known as function prototypes. How functions are called and their order of execution is illustrated. Statements, blocks, and functions define the structure of C programs.

Chapter 3, Working with Basic Data Types, explores how C represents values in various ways through the use of data types. Each data type has a size and possible range of values that C uses to interpret a value.

Chapter 4, Using Variables and Assignments, introduces variables and constants, which are used to contain values. For a variable to receive a value, that value must be assigned to it; several types of assignment are explained.

Chapter 5, Exploring Operators and Expressions, introduces and demonstrates operations – ways to manipulate values – on each of the various data types.

Chapter 6, Exploring Conditional Program Flow, introduces the flow of control statements, which execute one group of statements or another, depending on the result of an expression.

Chapter 7, Exploring Loops and Iterations, introduces each of the looping statements. It also describes the proper and improper use of goto. Additional means of controller loop iterations are explained.

Chapter 8, Creating and Using Enumerations, explains named constants, enumerations, and how to use them.

Part 2, Complex Data Types, extends your understanding of the concepts of basic, or intrinsic, data types to more complex types.

Chapter 9, Creating and Using Structures, explores how to represent complex objects with groups of variables, called structures. Operations on structures are explored. How structures are related to object-oriented programming is described.

Chapter 10, Creating Custom Data Types with typedef, describes how to rename enum and struct declarations. Compiler options and header files are explored.

Chapter 11, Working with Arrays, illustrates how to define, initialize, and access simple arrays. Using loops to traverse arrays is explored. Operating on arrays via functions is demonstrated.

Chapter 12, Working with Multi-Dimensional Arrays, extends your understanding of the concept of one-dimensional arrays to two-, three-, and n-dimensional ones. Declaring, initializing, and accessing these multi-dimensional arrays in loops and functions are demonstrated.

Chapter 13, Using Pointers, explores direct and indirect addressing with pointers. Operations with pointers are demonstrated. How to think and talk about pointers is described. Using pointers in functions and using pointers to structures is demonstrated.

Chapter 14, Understanding Arrays and Pointers, explores the similarities and differences between pointers and arrays.

Chapter 15, Working with Strings, introduces the ASCII character set and C strings, which are arrays with two special properties. A program to print the ASCII character set in a table is developed. The C standard library string operations are introduced.

Chapter 16, Creating and Using More Complex Structures, builds upon the concepts of structures and arrays to explore how to create various combinations of complex structures. Throughout the chapter, each complex structure is demonstrated through the development of a complete card-dealing program. This chapter provides the most comprehensive example of the method of stepwise, iterative program development.

Part 3, Memory Manipulation, explores how memory is allocated and deallocated in a variety of ways.

Chapter 17, Understanding Memory Allocation and Lifetime, introduces the concepts of automatic versus dynamic memory storage classes as well as internal versus external storage classes. The static storage class is demonstrated.

Chapter 18, Using Dynamic Memory Allocation, introduces the use of dynamic memory and describes various operations on dynamic memory. A dynamic linked-list program is demonstrated. An overview of other dynamic structures is provided.

Part 4, Input and Output, explores a wide variety of topics related to the reading (input) and writing (output) of values.

Chapter 19, Exploring Formatted Output, goes into thorough detail about the various format specifiers of printf() for each of the intrinsic data types: signed and unsigned integers, floats and doubles, and strings and characters.

Chapter 20, Getting Input from the Command Line, demonstrates how to usethe argc and argv parameters of main() to get values from the command line.

Chapter 21, Exploring Formatted Input, demonstrates how to read values from an input stream using scanf(). It clarifies how the format specifiers for printf() and scanf(), while similar, are really very different. Internal data conversion and unformatted input and output are also demonstrated.

Chapter 22, Working with Files, is a largely conceptual chapter that introduces basic file concepts. It demonstrates how to open and close files from within a program and from the command line.

Chapter 23, Using File Input and File Output, demonstrates how to use command-line switches with getopt() to read and write files. The basic program is then expanded to read names from input, sort them via a linked list, and then write them out in sorted order.

Part 5, Building Blocks for Larger Programs, details how to create and manage programs that consist of multiple files.

Chapter 24, Working with Multi-File Programs, demonstrates how to take the single source file program that was developed in Chapter 16, Creating and Using More Complex Structures, and separate it into multiple source files. Each of the source files has functions that are logically grouped by the structures they manipulate. Effective and safe uses for the preprocessor are described.

Chapter 25, Understanding Scope, defines various components of scope and how they relate to single- and multi-file programs. Details of variable scope and function scope are described.

Chapter 26, Building Multi-File Programs with make, introduces basic features of the make utility. make is then used to build a multi-file program. A general-purpose makefile is developed.

Chapter 27, Creating Two Card Programs, starts with the dealer program developed in Chapter 16, Creating and Using More Complex Structures, to create two different yet complete and playable card games: Blackjack, or 21, and One-Handed Solitaire. The user interface is limited to the command-line entry of characters.

The Epilogue outlines some useful next steps to take in learning both C and programming.

The Appendix provides a number of useful reference guides. These include C keywords, operator precedence, a summary of some useful GCC and Clang options, ASCII characters, using Bstrlib, a brief overview of Unicode, an annotated history of C versions, and an itemization of the C standard library.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime