Skip to main content

C Header Files

In C programming, a header file is a file that contains declarations of functions, variables, macros, and other data types, which are used in one or more source code files. The header files are included at the beginning of a C source file using the #include preprocessor directive.

Header files provide a way to modularize code and facilitate code reuse. They allow programmers to separate the interface of a module from its implementation, making it easier to maintain and update the code.

Some of the commonly used header files in C programming include stdio.h, stdlib.h, math.h, string.h, time.h, and ctype.h. These header files contain declarations of functions, constants, and other data types that are commonly used in C programming.

When a C program is compiled, the compiler reads the header files and uses the declarations to verify that the functions and variables used in the program are correctly defined.

Including header file syntax

//predefined header files
#include <file_name>

//user defined header file
#include <path_and_file_name>

<file_name> are indicates to that is inbuilt header file. Extension of header file is (.h) .header file are two type

Header File Type

Perdefined Header File

That is inbuilt header files of C programming language that are include when we are installed C compiler. Here given standard header file in c programming.

Here are some of the commonly used header files in C programming:

Here are some of the commonly used header files in C programming:

  • stdio.h - Contains input/output functions like printf, scanf, fopen, and fclose.
  • stdlib.h - Contains functions for memory allocation, exit functions like exit, and other utility functions like atoi and rand.
  • string.h - Contains functions for manipulating strings like strlen, strcpy, strcat, and strstr.
  • ctype.h - Contains functions for testing and manipulating characters like isalpha, isdigit, toupper, and tolower.
  • math.h - Contains mathematical functions like sin, cos, sqrt, and pow.
  • time.h - Contains functions for working with time and dates like time, strftime, and gmtime.
  • limits.h - Contains constants that represent the maximum and minimum values for various data types.
  • float.h - Contains constants that represent the precision and range of floating-point values.
  • stdbool.h - Contains definitions for the Boolean data type and values true and false.
  • assert.h - Contains the assert macro for debugging purposes.
  • complex.h - Contains functions for working with complex numbers.
  • errno.h - Contains error code values used by system functions.
  • fcntl.h - Contains constants for working with file descriptors.
  • locale.h - Contains functions for working with the locale settings.
  • signal.h - Contains functions for working with signals.
  • stdarg.h - Contains macros for handling variable argument lists.
  • stddef.h - Contains various definitions, such as NULL, size_t, and ptrdiff_t.
  • stdint.h - Contains integer type definitions with fixed bit widths.
  • stdio_ext.h - Contains non-standard I/O functions.
  • stdlib_ext.h - Contains non-standard utility functions.
  • sys/stat.h - Contains constants for file permissions and file types.
  • sys/types.h - Contains various system data types.
  • timeb.h - Contains the struct timeb for working with time values and time zones.
  • inttypes.h - Its provides macros for working with integer types of fixed widths. It was introduced in the C99 standard to provide a standardized way to define integer types that have a specific width across different platforms and compilers.

Note that there are many other header files in C, but the above-listed ones are the most commonly used in C programming.





Comment

Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.

New Comment