Linking a *.c with a *.h File

Question:
As a developer new to C (I’m using Borland C/C++ version 5), I am trying to understand the method of linking *.c and *.h files within an application.

First I wrote the one.h file. Next, I wrote the one.c file and placed the #include “one.h” statement in its declarations section.

Using the Borland IDE, how do you link the files so that they can be compiled as one application?

Answer:
Once you #include the header file, you simply compile the .c source file. The declarations within the header file are compiled too because the compiler considers the header as an integral part of the source file (in other words, the effect of #including a header in a source file is as if you had copied and pasted the header into the beginning of the source file). Most IDEs automatically link the resultant object file and, if all is well, you can immediately run the executable produced. Make sure your source file contains “main()”.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: