Chapter 8. Static and Dynamic Libraries: Hot-swappable code

image with no caption

You’ve already seen the power of standard libraries.

Now it’s time to use that power for your own code. In this chapter, you’ll see how to create your own libraries and reuse the same code across several programs. What’s more, you’ll learn how to share code at runtime with dynamic libraries. You’ll learn the secrets of the coding gurus. And by the end of the chapter, you’ll be able to write code that you can scale and manage simply and efficiently.

Code you can take to the bank

Do you remember the encrypt() function you wrote a while back that encrypted the contents of a string? It was in a separate source code file that could be used by several programs:

image with no caption

Somebody else has written a function called checksum() that can be used to check if the contents of a string have been modified. Encrypting data and checking if data has been modified are both important for security. Separately, the two functions are useful, but together they could form the basis of a security library.

image with no caption
image with no caption

Get Head First C now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.