C Preprocessor File Inclusion

  • By using C Preprocessor File Inclusion, we can include a file into another file like .h,.c,.cpp,.rc.
  • Generating by using # we are including header files.
  • A header of file is a source file which contains forward declaration of predefined function, global, variables, constant values, predefined data types, predefined structures, predefined macros and inline functions.
  • .h file is a collection of functions.
  • Source code is a combination of predefined and user-defined functions.
  • Normal .c file contains implementation part of user-defined functions, calling statement of predefined functions.
  • Generally coding part of user-defined function available in normal object file but predefined function coding part is available in .lib or .obj files which is linking to the application at the time of linking.
  • If it is user-defined function or predefined function, coding part is mandatory.
  • As per the function concept if it is user-defined or predefined function, forward declaration is required for both functions.
  • All predefined functions wil be loaded into the application at the tie of linking i.e. after compilation process only. That means we are calling the predefined function then it becomes user-defined function so required to go for header file.
  • .h file will provides forward declaration of predefined functions.
  • .h file will not be compiled but .h file will be compiled, because at the time of preprocessing complete . file code will be substituted in source code and alon with source code header file code will be compiled
  • .

Syntax:

#include
#include “filename.h”

Examples:

#include
#include #include
#include
#include

Powered by k2schools