C Header Files

C provides a lot of header files to handle functions defined in the C standard library. The headers that relate to the functions you use in your programs are included using #include. The most common header file is <stdio.h>, provides the type FILE that is necessary for disk file operations.

C Header Files List

Here this table lists C header files.

Header File Use
<assert.h> defines the assert() macro
<ctype.h> character handling
<errno.h> error reporting
<float.h> defines implementation-dependent floating-point limits
<limits.h> defines various implementation-dependent limits
<locale.h> supports localization
<math.h> various definitions used by the math library
<setjmp.h> supports non-local jumps
<signal.h> supports signal handling
<stdarg.h> supports variable argument lists
<stddef.h> defines some commonly used constants
<stdio.h> supports the I/O system
<stdlib.h> miscellaneous declarations
<string.h> supports string functions
<time.h> supports system time functions
<complex.h> supports complex arithmetic
<fenv.h> gives access to the floating-point status flags and other aspects of the floating-point environment
<inttypes.h> defines a standard, portable set of integer type names. Also supports the functions that handle greatest-width integers
<iso646.h> defines macros that corresponds to various operators, such as && and ^
<stdbool.h> supports boolean data types, this defines the macro bool, which helps C++ compatibility.
<stdint.h> defines a standard, portable set of integer type names, this file included by the header file <inttypes.h>
<tgmath.h> defines type-generic floating-point macros
<wchar.h> supports multibyte and wide-character functions
<wctype.h> supports multibyte and wide-character classification functions

How to include header file in a C program ?

Both user and system header files are included using the preprocessor directive #include. It has the following two forms. Here this form is used to include the system header files.


And now, this form is used to include the header files of your own program. In other words, this syntax is used to include user-defined header files.

#include "filename.h"

For example, if you want to include system header file say <stdio.h>. Use this:


And if you want to include your own header file that you made say <myheader.h>. Then use this:

#include "myheader.h"

Define and Use Your own Header Files

To define and use your own header files, provides simplicity in programming. Let's suppose you are working on a large project, and you required a lot of functions to use in your project. Then if you put all the functions in a program, then it becomes hard to read for others. And sometimes the programmer also becomes confuse on viewing the code later. So to make a large project smaller, you can put all your functions in a external file with .h extension also called as user-defined header files. Here is an example.

Let's first create a file say myheader.h and put the following code inside that file.

int square(int a)
   return a*a;

int sum(int a, int b)
   return a+b;

int subtract(int a, int b)
   return a-b;

void welcome(void)
   printf("Welcome to C Programming\n");

Now you have created your own header file named "myheader.h", having the above functions. Now just concentrate on this program. Here we included the above header file i.e., "myheader.h" and will use a function square(). Let's look at the following example program to understand it completely:


// now including our own header file myheader.h
#include "myheader.h"

void main()
   int num;

   printf("Enter a number: ");
   scanf("%d", &num);
   printf("Square of %d is %d", num, square(num));


As you can see, we have included the header file "myheader.h" and used the function square() of that header file to find the square of a number entered by the user. Here is the sample run of this C program.

c header files

Here is one more example program that also uses the same user-defined header file i.e., "myheader.h" to use rest functions.

#include "myheader.h"

void main()
   int num1, num2;

   printf("Enter the two number: ");
   scanf("%d%d", &num1, &num2);
   printf("Sum of %d and %d is %d", num1, num2, sum(num1, num2));
   printf("\nSubtract of %d and %d is %d", num1, num2, subtract(num1, num2));


Here is the sample output of the above C program:

c header files list

As you can see from the above two programs, we have created only one header file named "myheader.h" and used it two times. So it makes program more simple. You can also create your own header file, and define all the function inside it to use those functions in your program any time in any program, just after including a header file say "myheader.h".

C Online Test

« Previous Tutorial Next Tutorial »

Follow/Like Us on Facebook

Subscribe Us on YouTube