Library Functions:
There
are certain set of general purpose operations which are quite frequently used
by the programmers in their programs. For example: To calculate the square root
of a number, to calculate power of a number, to calculate the length of the
string, to perform input/output and many more. Making functions for performing
these operations in every program is unnecessary and a time consuming job. So
these general purpose operations are programmed and stored in C library so that
they can be called through any program in the form of functions. These
functions are the library functions.
The library functions are predefined
and precompiled functions that are designed to perform some specific task.
Information is passed to these functions via arguments and return via the
return statement. Before using library function in the program, it is necessary
to include the corresponding header file using #include directive. The header file
contains the information about library functions (function prototype) and
actual coding (function definition) is available in the object code form in the
library file.
There
are a number of library functions available in C. Some of the library functions
and their corresponding header files are given below.
a.
Library functions that carry out standard input/output
operations. Some of these include scanf ( ), printf ( ), getchar ( ), fclose (
), fopen ( ) etc. These functions are included in stdio.h header file.
Beside these, some other library functions that are part of
stdio.h library file are fclose ( ), feof ( ), fgetc ( ), fopen ( ), fopen ( ),
fprintf ( ), fputs ( ), fread ( ).
b. Library
functions that carry out operations on argument of type character. Some of
these include tolower ( ), toupper ( ) etc. Theseare collectively grouped under
ctype.h header file.
Some
other library functions available in this header file are isalnum ( ), iscntrl
( ), isgraph ( ), islower ( ), islower ( ), isodigit ( ). All these functions
return non-zero value if true, 0 otherwise.
c.
Library functions that perform operations on strings: Some of
these include strcmp ( ), strcpy ( ), strlen ( ) etc. These are collectively
grouped in string.h header file.
Post a Comment