Skip to Content
Smaller C
book

Smaller C

by Marc Loy
May 2021
Intermediate to advanced
311 pages
7h 45m
English
O'Reilly Media, Inc.
Content preview from Smaller C

Chapter 5. Functions

With the various assignment statements and flow of control options we’ve seen so far, you are now primed to solve just about any problem meant for computers. But solving a problem turns out to be only about half of the, uh, problem. Whether you are coding for work or for fun, you invariably need to go back to code you have already written. You might be fixing a small bug or adding a missing feature. You may be using a previous project as a starting point for a new one. In all of these moments, the maintainability of your code becomes almost as important as the initial effort to get the code working. Breaking up a problem to make it manageable while you are solving it can have a beneficial effect on the code you end up writing—which also has a beneficial effect on its readability and maintainability.

Core to this idea of tackling smaller problems on the way to tackling the whole one is the use of functions or procedures. Functions help you encapsulate logic—the statements and control structures you are learning to code. In C, you can write and call as many functions as you need.1 C doesn’t really distinguish between the word “function” and the word “procedure,” although some languages do. (In those languages, the difference is often whether or not a piece of code returns a value or simply executes a set of statements.) I’ll mostly use the term function, but if you see discussions of a procedure (or routine, same idea) here or in any of your other reading, it ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Intermediate C Programming for the PIC Microcontroller: Simplifying Embedded Programming

Intermediate C Programming for the PIC Microcontroller: Simplifying Embedded Programming

Hubert Henry Ward

Publisher Resources

ISBN: 9781098100322Errata Page