Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
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 C programming the easy and disciplined way

Arrow left icon
Product type Paperback
Published in Jun 2020
Publisher Packt
ISBN-13 9781789349917
Length 646 pages
Edition 1st 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 (33) Chapters Close

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

To get the most out of this book

To use this book, you will need a basic text editor, a terminal or console application, and a compiler. Descriptions of each of these and how to download and use them are provided in Chapter 1, Running Hello, World!. Here are the technical requirements for this book:

Operating System Cost Download URL
Linux/Unix
Text Editor(choose one)
Nano Free https://www.nano-editor.org/download.php
Vim or vi <Built-in> N/A
GEdit <Built-in> https://wiki.gnome.org/Apps/Gedit
Emacs Free https://www.gnu.org/software/emacs/download.html
Compiler (Installation based on version of Linux/Unix)
GCC <Built-in>

https://gcc.gnu.org/install/ (see the notes following this table for certain Linux versions)

Terminal
Terminal <Built-in> N/A
macOS
Text Editor(choose one)
Vim or vi <Built-in> N/A
emacs Free https://www.gnu.org/software/emacs/download.html
Bbedit Free https://www.barebones.com/products/bbedit/
Compiler
Clang <Built-in>
Terminal
terminal.app <Built-in> N/A
Windows
Text Editor(choose one)
Notepad <Built-in> N/A
Notepad++ Free https://notepad-plus-plus.org/downloads/
emacs Free https://www.gnu.org/software/emacs/download.html
Compiler
Cygwin Free http://www.cygwin.com
MinGW Free http://mingw-w64.org
Terminal
Console <Built-in> N/A

To install GCC on certain Linux OSes, follow these steps:

  • If you are running an RPM-based Linux, such as RedHat, Fedora, or CentOS, on the command line in Terminal, enter the following:
$ sudo yum group install development-tools
  • If you are running Debian Linux, on the command line in Terminal, enter the following:
$ sudo apt-get install build-essential

To verify your installation of GCC or Clang for any platform, on the command line in the Terminal, enter the following:

$ cc --version

Whichever version of this book you are using, digital or hard copy, we advise you to type the code yourself. After you do that, you can access the code via the GitHub repository (link available in the next section). Doing so will help you avoid any potential errors related tothe copying and pasting of code.

If you are an absolute beginner, once you have the necessary development tools, you will need to learn how to read a programming book. If you have taken an algebra course or a calculus course in school, then you will need to approach learning from a programming book in a similar fashion:

  1. Read through the chapter to get an overview of the concepts being presented.
  2. Begin the chapter again, this time typing in each program as you encounter it. Make sure you get the expected output before moving on. If you don't get the expected output, try to figure out what is different in your program from the one given. Learning to program is a lot like learning math—youmustdo the exercises and get the programs to work. You cannot learn to program just by looking at programs; to learn to program, you must program. There is no way around that.
  3. Focus upon memorizing keywords and syntax. This will greatly speed up your learning time.
  1. Be aware that you will need to sharpen the precision of your thinking. Computer language syntax is extremely precise and you will need to pay extra attention to it. You will also have to think much more precisely and in sometimes excruciating detail about the steps needed to solve a particular problem.
  2. Review both the concepts and example programs. Make a note of anything you don't understand.

If you are an experienced programmer who is new to C, I still strongly advise you to first skim the text and examples. Then, enter the programs and get them to work on your system. This will help you to learn C syntax and its idioms more quickly.

I have found that it is important to understand what kind of book you are reading so that you can use it in the most appropriate way. There are several kinds of computer programming books:

  • Conceptual books, which deal with the underlying ideas and motivation for the topics they present. Kernighan and Ritchie'sThe C Programming Languageis one such book.
  • Textbooksthat go through every major area of the language, sometimes in gory detail and usually with a lot of code snippets. Deitel and Deitel's books, as well asC Programming: A Modern Approach, by K. N. King, are examples of these. They are often best used in a formal programming course.
  • Reference books,which describe the specifics of each syntax element.C: A Reference Manual, by Harbison and Steele, is one such book.
  • Cookbooks, which present specific solutions to specific problems in a given language.Advanced C Programming by Example, by Perry, Expert C Programming: Deep Secrets, by Van Der Linden, andAlgorithms in C, by Sedgewick, are examples of these.
  • Topical books, which delve deeply into one or more aspects of a programing language.Pointers in C, by Reek, is one example.
  • Practice books, which deal with how to address programming with C generally.C Interfaces and Implementations, by Hanson, and21st Century C: C Tips from the New School, by Klemens, are two examples of these.

There are different ways to use these books. For instance, read a conceptual book once, but keep a reference book around and use it often. Try to find cookbooks that offer the kinds of programs you are likely to need and use them as needed.

I think of this book as a combination of a C cookbook, a C reference book, and a C practice book. All of the programs are working examples that can be used to verify how your compiler behaves on your system. Enough of the C language has been included that it may also be used as afirst approximationreference. Throughout, my intent has been to show good programming practice with C.

I would expect that Learn C Programmingwill not be your last book on C. When you consider other C books, be sure that they pertain to C99 at a minimum; ideally, they should include C11 or C18. Most C code before C99 is definitely old school; more effective programming practices and methods have been developed since before C99.

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
Banner background image