The #include Preprocessor Directive
The # includes directive loads specified file in the current program. The macros and functions of a loaded file can be called in the current program. The included file is compiled with the current program. The syntax is as given below.
# include "filename"
# include < filename>
Where, # is a symbol used with directives.
The file name is included in the double quotation mark, which indicates that the search for the file is made in the current directory and in the standard directories.
Example
# include "stdio.h"
When the file name is included without double quotation marks, the search for the file, is made only in the standard directories.
Example
# include <stdio.h>
# include <udf.h>
Write a program to call the function defined in "udf.c" file
# include <stdio.h>
# include <conio.h>
# include "udf.c"
void main ()
{
}
display ();
OUTPUT:
Function Called
Contents of udf.c file.
int display ();
display ()
{
printf ("\n Function Called");
return 0;
}
Explanation: In the first program the "udf.c" is included. It is a user defined function file. It is included before the main program is compiled. The complete program along with the included one is executed. The output of the program "Function Called" is displayed.
Social Plugin