------------------------------------------------------------------------------
MC logo
Point Header File
[^] Code Examples
------------------------------------------------------------------------------
<<Multi-File Programs cpoint.h Point Implementation File>>
/*
 * C Header file for points.
 */

/* Points. */
typedef struct Point {
        double xval, yval;
} Point;

/* Operations on points */
Point mkpt(double x, double y);
double dist(Point a, Point b);
Point add(Point a, Point b);
Point sub(Point a, Point b);
void move(Point *p, double a, double b);
void print(Point p);

This and the two following files form the same program as the simple C point demo earlier. To compile, use these steps.
  1. Say gcc -c cpoint.c. This compiles the point ADT and produces the file cpoint.o. The cpoint.h file is read by the #include directive during the compile.

  2. Say gcc -c cpointu.c. This compiles the point ADT and produces the file cpointu.o. The cpoint.h file is again read by the during this compile.

  3. Say gcc -o cpoint cpoint.o cpointu.o to combine the two object files into an executable cpoint.
Of course, you could just say gcc -o cpoint cpoint.c cpointu.cb and have it do all the steps for you, but that wouldn't be nearly so much fun.
<<Multi-File Programs Point Implementation File>>