Pages

Tuesday, December 14, 2010

C header files

Header file is defined as a "collection of functions of similar type". In C there are many inbuilt or library functions like "printf(), scanf(), strcmp(), getch()" etc. Each of these function is defined in the C library in a header file. For example the string functions are defined in the header file "string.h" , whereas mathematical functions are given in the header file "math.h". When the user writes any of these functions, the compiler reads the definition from the included header file and knows what this function is , how does it work etc.
In C applications are divided into smaller parts through the use of header files.Any function prototype, and type definitions that can be exported from a source code file are put in a header file. From the point of view of the main application, these functions are external.The compiler reads the included header file and knows where a particular function comes from. Without this it would just report an undefined function error.In C a header file has the extension ".h" which denotes that is a header file. Following are the most used header files along with their description
Contains defined constants specifying the implementation-specific properties of the floating-point library, such as the minimum difference between two different floating-point numbers, the maximum number of digits of accuracy (_DIG) and the range of numbers which can be represented (_MIN, _MAX).
Header File Name Description

assert.h
Contains the assert macro, used to assist with detecting logical errors and other types of bug in debugging versions of a program.
complex.h A set of functions for manipulating complex numbers.
ctype.h Contains functions used to classify characters by their types or to convert between upper and lower case in a way that is independent of the used character set

errno.h
For testing error codes reported by library functions.
float.h
inttypes.h For precise conversion between integer types.
limits.h Contains defined constants specifying the implementation-specific properties of the integer types, such as the range of numbers which can be represented (_MIN, _MAX).

locale.h
For setlocale and related constants. This is used to choose an appropriate locale.
math.h For computing common mathematical functions.
setjmp.h Declares the macros setjmp and longjmp, which are used for non-local exits.
signal.h For controlling various exceptional conditions.
stdarg.h For accessing a varying number of arguments passed to functions.
stdbool.h For a boolean data type.
stdint.h For defining various integer types.
stddef.h For defining several useful types and macros.
stdio.hProvides the core input and output capabilities of the C language. This file includes the venerable printf function.
stdlib.h For performing a variety of operations, including conversion, pseudo-random numbers, memory allocation, process control, environment, signalling, searching, and sorting
string.h For manipulating several kinds of strings.
time.h For converting between various time and date formats.

0 comments:

Post a Comment