A proper example (in C, for C++ you would want to use ".cpp" files instead of ".c", and you would use "<iostream>" and "std::cout" instead of "puts".
foo.h, declares some functions, which will be defined in another file.
CODE
#ifndef _FOO_H // These make sure this header file is only included once.
#define _FOO_H
void foo(void);
#endif
foo.c, includes the above header file and defines the functions in it.
CODE
#include "foo.h"
#include <stdio.h>
#include <stdlib.h>
void foo(void)
{
puts("Hello world!");
}
main.cCODE
#include "foo.h"
#include <stdio.h>
#include <stdlib.h>
int main()
{
foo(); // Call foo.
return EXIT_SUCCESS;
}
If you already declared your functions/variables in a header file, and you've included that header file, then you don't have to declare them again in your source file(s).