- Let's take a quick look at the original exercise file
in Chapter 7, 07_02.c.
That file, as you recall, includes a lengthy
prototype section, a lengthier main section
and lots of functions that it calls.
The solution in this case, it's quite simple.
We're going to move everything except what is in main.
In transactions.h and transactions.c which is
the file names I chose for this project.
You can choose any other files.
I moved all the prototype functions
and, in addition to that, the include stdio and stdlib
and I defined the global variables as well.
In transaction.c we still need to include the
two libraries because they are used by this function
in this file.
That's all there is to it.
Now if we examine the original file, all there is,
it's an include to transactions.h which also
has inside it the include to the standard libraries
so we don't even need those in here,
and the main.
We created now a solution in which we have three files,
they're much more manageable, they're much shorter,
it's easier to find information, and they can
be actually shared with other projects
should you choose to do so.
If you look at transactions.h, it is very clear
in a very short file, what functions are available
for someone to use.
A different person may not even care about how
this functions have been implemented.
All that person needs to know is the name of the function
and what type of variable.
If someone wants to know all the details,
they're available in transactions.c.