Dividing Programs into Modules
In This Chapter
Breaking programs down into functions
Writing and using functions
Returning values from a function
Passing values to a function
Providing a function prototype declaration
In Chapter 11, I show you how to divide a complex problem into a number of separate functions; it is much easier to write and get a number of smaller functions to work than one large, monolithic program. Often, however, you may want to reuse the functions you create in other applications. For example, I could imagine reusing the factorial() function created in Chapter 11.
One way to reuse such functions is to copy-and-paste the source code for the factorial() function into my new program. However, it would be a lot easier if I could put the function in a separate file that I could then link into future applications. Breaking programs into separate source code modules is the subject of this chapter.
Breaking Programs Apart
The programmer can break a single ...