Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
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

Installing a compiler on Linux, macOS, or Windows

Here are the steps to follow to install a C compiler on the major desktop computer environments – Linux, macOS, and Windows. For other platforms, you'll have to do some investigation to find the compiler you need. However, since those platforms want you to use them, they'll likely make those instructions easy to find and follow:

  • Linux:
    1. If you are running a Red Hat Package Manager (RPM)-based Linux, such as RedHat, Fedora, or CentOS, enter this command from the command line:
      $ sudo yum group install development-tools
    2. If you are running Debian Linux, open a Terminal window and enter this command from the command line:
      $ sudo apt-get install build-essential
    3. Verify your installation by entering this command from the command line:
      $ cc --version
    4. From the preceding command, you will see that you likely have GCC or clang. Either one is fine. You are now ready to compile C programs on your version of Linux.
  • macOS:
    1. Open Terminal.app and enter the following at the command line:
      $ cc --version
    2. If the development tools have not been installed yet, simply invoking the preceding command will guide you through their installation.
    3. Once the installation is complete, close the Terminal window, open a new one, and enter the following:
      $ cc --version
    4. You are now ready to compile C programs on your version of macOS.
  • Windows:
    1. Install either Cygwin (http://www.cygwin.com) or MinGW (http://mingw-w64.org/) from their respective websites. Either one will work well. If you choose to install Cygwin, be sure to also install the extra package for the GNU Compiler Collection (GCC). This will install a number of other required compiler and debugging programs with GCC.
    2. Once the installation is complete, open a Command Prompt and enter the following:
      $ cc --version
    3. You are now ready to compile C programs on your version of Windows.

Compilation is a two-part process – compiling and linking. Compiling involves syntax checking and converting source code into nearly-complete executable code. In the linking phase, the nearly-complete machine code is merged with the runtime library and becomes complete. Typically, when we invoke the compiler, the linker is also invoked. If the compiler phase succeeds (no errors), the linking phase is automatically invoked. Later, we will see that we can get error messages from the compiler either at compile-time – the compiling phase – or at link-time – the linking phase – when all the program's pieces are linked together.

We will learn how to invoke the compiler later when we compile our first program.

Throughout this book, once you have a working program, you will be directed to purposely break it – cause the compilation of your program to fail – so that you can start learning about the correlation of various program errors with compiler errors and so that you will not be afraid of breaking your program. You will simply undo the change and success will be yours once more.

You have been reading a chapter from
Learn C Programming
Published in: Jun 2020
Publisher: Packt
ISBN-13: 9781789349917
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