Work of include directive in C/C++.


In this post we are going to understand what is include directive? And how it works? Also at the end of the post i had listed all the necessary header files which are used in C/C++ programming.


1. What is include directive?

      Many programming languages have a directive often called as include (as well copy or import) that causes the content of another file to be copied into the original file.This include files are also called as copybooks or header files.They are often used to define physical layout of a program and for forward deceleration.

Forward deceleration is a deceleration of identifiers for which programmer has not yet given complete definition.

2.Working of include directive. 

     There are two methods to include a file in a program as shown below:

              1. #include<header file name>
              2. #include"header file name"

     In C and C++, the #include  preprocessor directive causes the compiler to replace that line with the entire text of the contents of the named source file (if included in quotes: "") or named header (if included in angle brackets: <>).

3. List of C/C++ Header files.

<cassert> (assert.h)   C Diagnostics Library (header)
<cctype> (ctype.h)    Character handling functions (header)
<cerrno> (errno.h)     C Errors (header)
<cfenv> (fenv.h)        Floating-point environment (header)
<cfloat> (float.h)       Characteristics of floating-point types (header)
<cinttypes> (inttypes.h)   C integer types (header)
<ciso646> (iso646.h)       ISO 646 Alternative operator spellings (header)
<climits> (limits.h)          Sizes of integral types (header)
<clocale> (locale.h)         C localization library (header)
<cmath> (math.h)            C numerics library (header)
<csetjmp> (setjmp.h)       Non local jumps (header)
<csignal> (signal.h)         C library to handle signals (header)
<cstdarg> (stdarg.h)         Variable arguments handling (header)
<cstdbool> (stdbool.h)     Boolean type (header)
<cstddef> (stddef.h)         C Standard definitions (header)
<cstdint> (stdint.h)           Integer types (header)
<cstdio> (stdio.h)             C library to perform Input/Output operations (header)
<cstdlib> (stdlib.h)           C Standard General Utilities Library (header)
<cstring> (string.h)          C Strings (header)
<ctgmath> (tgmath.h)      Type-generic math (header)
<ctime> (time.h)              C Time Library (header)
<cuchar> (uchar.h)          Unicode characters (header)
<cwchar> (wchar.h)        Wide characters (header)
<cwctype> (wctype.h)     Wide character type (header)

Comments