Post

Chapter 13: C Libraries and Header Files

Learn how to use libraries and header files in C.

Chapter 13: C Libraries and Header Files

Table of Contents

13.1 Standard Libraries

C provides many libraries, e.g., <stdio.h>, <stdlib.h>, <string.h>.

13.2 Creating and Using Header Files

Header files allow you to declare functions and share code between files.

13.3 Exercises

  1. List three standard C library headers.
  2. Write a header file declaring a function int add(int, int);.
  3. How do you include a header file in your program?

13.4 Solutions

13.4.1 Solution 1

<stdio.h>, <stdlib.h>, <string.h>

13.4.2 Solution 2

1
2
// mymath.h
int add(int, int);

13.4.3 Solution 3

Use #include "mymath.h"

13.5 What’s Coming in the Next Chapter

Next, you’ll learn about debugging and best practices in C!

Next Chapter → Debugging, Warnings, and Best Practices

This post is licensed under CC BY 4.0 by the author.