30. Organizing Your Programs with Functions
In This Chapter
• Adding functions to programs
• Choosing between global and local variables
Typical computer programs are not the 20- to 30-line variety that you see in textbooks. In the “real world,” computer programs are much longer—but long programs contain lots of code that can get in the way while learning new concepts. That’s why, until this point, you’ve seen fairly short programs that contain all their code in main()
.
If you were to put an entire long program in main()
, you would spend a lot of time trying to find anything specific if you later needed to change it. This chapter is the first of three chapters that explore ways to partition your programs into sections via multiple functions. ...
Get C Programming Absolute Beginner’s Guide, Third Edition 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.