What is a header file in c program


What is a header file in c program

#include<stdio.h>

It is a pre-processor file inclusion directive statement that search for the file specified within <> in standard file inclusion directory and if the file is found then the substitute it’s content in the program before compilation.
                Stdio.h is header file that contains the prototypes(declarations) for the built in standard Input output functions and necessary macro substitution directories. If the built in functions for the standard Input Output operations are invoked in a C program, then this file has to be included using file inclusion directive.
                If the built-in function for standard I/O operations are invoked without including the header file stdio.h then for each of the function called in the program, a compile time error is reported saying “prototype missing”.

Example: ‘printf()’ should have a prototype.

Difference between #include<file_name> and #include“file_name”:

#include<file_name>

File is searched by the pre-processor in pre-defined file inclusion directory.

#include“file_name”

File is searched in present working directory. If no absolute path is given using this a file from a specific part apart from the file inclusion directory or present working directory can be included by specifying absolute path of the file name.

Example: #include “F:\\Myfile\x.h”

No comments

Powered by Blogger.