devxlogo

Linking a *.c with a *.h File

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()”.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist