Home Segments Index Top Previous Next

652: Mainline

Fortunately, the C compiler does not need to know about the complete function definitions. You can provide the C compiler with the information it needs to compile the main.c file by collecting information about the trades.c file in a new header file named trades.h:

/* Trades declaration file (h extension) */ 
/* Define the trade structure */ 
struct trade {double price; int number;}; 
/* Specify function prototypes */ 
double mean_price (struct trade **, int); 
double mean_size (struct trade **, int); 

Once you have constructed the trades.h file, your C compiler can work on main.c as long as you provide access to the trades.h file via an #include declaration in the main.c file:

... 
#include "trades.h" 
... 

As far as the C is concerned, it is as though the complete text of the included file appeared at the place where the inclusion occurs.