12.7 – File inclusions and setting up environment in Turbo C

by subbu on December 20, 2013

File inclusion and setting up environment in Turbo C:

It is the second important preprocessor directive. It helps to import and attach the contents of one file into another automatically by the preprocessor. It is generally used on two purposes

  • If we have a very large program, then it is a better programming practice to divide different sections of the program as different files and linked together.
  • If we have some commonly used functions, macros and constants then these can be defined as a separate file and then can be included into any program as we need

What is header file?

Header file is a collection of functions, macros and constants mostly belongs to the same category saved with .h extension (not compulsory).

When we specify the file name with #include directive then the preprocessor automatically includes the contents of header file into the program (as simple as copy and past)

How to write #include statement?

#include statement can be written in two forms, that are

#include "file name"


#include <file name>

In the first form, file name is placed in double quotes so that the preprocessor looks for the header file in the current directory and then in the specified list of directories set with the include option

In the second form, file name is placed in angular brackets so that the preprocessor looks for the file in the specified list of directories set with the include option

How to set the include search path for Turbo C?

As explained in the previous session under 1.2 How to install Turbo C in Windows XP/Vista, Turbo C has include folder where all the system defined header files are loaded by default.

Turbo C include path

To access these header files, we need to specify the location of include folder in the Directories option under Options menu

Select Options (Alt+O), Directories (D)

Turbo C Directories

Here the include folder is set as c:\tc\include, hence only searches in this location for a header file written with #include statement

How to set multiple include search paths?

Yes, it is possible to add more than one include search paths by adding all the paths separated with semicolon.

Include Directories: c:\tc\include;c:\subbu;d:\fox

Turbo C search path

The above “option set” helps to search in different locations for a header file specified with the #include statement

Saving the options

We have to save the options whenever we modify the options otherwise changed settings may not come into action. To save the options,

Select Options(Alt+O), Save (S)

Saving Turbo C options

For windows 7/8 users:

If any body installs the Turbo C on DOSBOX in windows 7/8 as discoursed in the previous session 1.3 How to install Turbo C in Windows 7/8 then the include path may change

Turbo C include path

Though the physical path of Turbo C here is c:\TurboC++\Disk\TurboC3, the relative path is c:\turboc3

So the Directory options must be set as

Turbo C directories 7/8

Here the output directory is set to c:\turboc3\source, hence all the object files and executable files generated by the compiler would be stored in “source”

Previous post:

Next post: