|
You might have: /*--------------------------------------------------------------*/ /* sum.h */ int sum(int x, int y);
/*--------------------------------------------------------------*/
/* main.c */
#include <stdio.h>
#include "sum.h"
int main(void)
{
int a = 3;
int b = 4;
int c;
c = sum(a, b);
printf("Sum of %d and %d is %d.\n", a, b, c);
}
/*--------------------------------------------------------------*/
/* sum.c */
#include <stdio.h>
#include "sum.h"
int sum(int x, int y)
{
int result;
result = x + y;
return result;
}
To build this program, you might do: cc sum.c main.c -o my_sum Or, to compile and link separately: cc -c sum.c cc -c main.c cc sum.o main.o -o my_sum Each time you made a change to sum.h, main.c or sum.c, you would re-type these commands. |