Вы находитесь на странице: 1из 9

Monceda, Catherine H.

BSCE-2 ES201
C Programming Libraries and their Functions

S.No Header file Description

1 stdio.h This is standard input/output header file in which Input/Output functions are declared

2 conio.h This is console input/output header file

3 string.h All string related functions are defined in this header file

4 stdlib.h This header file contains general functions used in C programs

5 math.h All maths related functions are defined in this header file

6 time.h This header file contains time and clock related functions

7 ctype.h All character handling functions are defined in this header file

8 stdarg.h Variable argument functions are declared in this header file

9 signal.h Signal handling functions are declared in this file

10 setjmp.h This file contains all jump functions

11 locale.h This file contains locale functions

12 errno.h Error handling functions are given in this file

13 assert.h This contains diagnostics functions

C – stdio.h library functions

LIST OF INBUILT C FUNCTIONS IN STDIO.H FILE:

S.no Function Description

This function is used to print the character, string, float, integer, octal and hexadecimal values onto
the output screen.
printf()
1 intprintf(constchar*format,...)

This function is used to read a character, string, numeric data from keyboard.

2 scanf() intscanf(constchar*format,...)

It reads character from file

3 getc() intgetc(FILE *stream)

It reads line from keyboard

4 gets() char*gets(char*str)

It reads character from keyboard

5 getchar() intgetchar(void)

It writes line to o/p screen

6 puts() intputs(constchar*str)

It writes a character to screen

7 putchar() int putchar(intchar)

This function clears the error indicators

8 clearerr() void clearerr(FILE *stream)

All file handling functions are defined in stdio.h header file

9 f open() FILE *fopen(constchar*filename,constchar*mode)

closes an opened file

10 f close() intfclose(FILE *stream)


Monceda, Catherine H. BSCE-2 ES201
reads an integer from file

11 getw() intgetw(FILE *stream)

writes an integer to file

intputw( int c, FILE * stream )


12 putw()

reads a character from file

13 f getc() intfgetc(FILE *stream)

writes a character to file

14 putc() intputc(intchar, FILE *stream)

writes a character to file

15 f putc() int fputc(intchar, FILE *stream)

reads string from a file, one line at a time

16 f gets() intgetc(FILE *stream)

writes string to a file

17 f puts() int fputs(constchar*s, FILE *stream)

finds end of file

18 f eof() int feof (FILE *stream)

reads a character from keyboard

19 f getchar int _fgetchar( void )

writes formatted data to a file

21 f printf() int fprintf (FILE *stream, const char *template, ...)

reads formatted data from a file

22 f scanf() int fscanf (FILE *stream, const char *template, ...)

writes a character from keyboard

24 f putchar intputchar(intchar)

moves file pointer position to given location

25 f seek() int fseek (FILE *stream, long int offset, int whence)

moves file pointer position to the beginning of the file

26 SEEK_SET int SEEK_SET

moves file pointer position to given location

27 SEEK_CUR int SEEK_CUR

moves file pointer position to the end of file.

28 SEEK_END int SEEK_END

gives current position of file pointer

29 f tell() long int ftell (FILE *stream)

moves file pointer position to the beginning of the file

30 rewind() void rewind (FILE *stream)

writes a character to file

31 putc() intputc(intchar, FILE *stream)

writes formatted output to string

32 sprint() int sprintf (char *s, const char *template, ...)


Monceda, Catherine H. BSCE-2 ES201
Reads formatted input from a string

33 sscanf() intsscanf(constchar*str,constchar*format,...)

deletes a file

34 remove() intremove(constchar*filename)

flushes a file

35 fflush() int fflush (FILE *stream)

C – conio.h library functions

LIST OF INBUILT C FUNCTIONS IN CONIO.H FILE:

S.no Function Description

This function is used to clear the output screen.

1 clrscr() clrscr();

It reads character from keyboard

2 getch() getch();

It reads character from keyboard and echoes to o/p screen

3 getche() getche();

This function is used to change the text color

4 textcolor() void textcolor(int color);

This function is used to change text background

5 textbackground() void textbackground(int color);

C – string.h library functions

LIST OF INBUILT C FUNCTIONS IN STRING.H FILE:

S.no string functions Description

Concatenates str2 at the end of str1.

1 strcat(str1, str2) char *strcat( char *str1, const char *str2 )

Copies str2 into str1

char *strcpy( char *str1, char *str2)


2 strcpy(str1, str2)

gives the length of str1.

size_tstrlen(const char *str1)


3 strlen(str1)

Returns 0 if str1 is same as str2. Returns <0 if strl < str2. Returns >0 if str1 > str2.

intstrcmp(const char *str1, const char *str2)


4 strcmp(str1, str2)

Returns pointer to first occurrence of char in str1.

char *strchr(char *str, int ch)


5 strchr(str1,char)

Returns pointer to first occurrence of str2 in str1.

char *strstr(char *str, char *srch_term)


6 strstr(str1, str2)

Same as strcmp() function. But, this function negotiates case. “A” and “a” are treated as
same.

7 strcmpi(str1,str2) int strcmpi ( const char * str1, const char * str2 )


Monceda, Catherine H. BSCE-2 ES201
duplicates the string

8 strdup() char *strdup(const char *string)

converts string to lowercase

9 strlwr() char *strlwr(char *string)

appends a portion of string to another

char *strncat(char *str1, char *str2, int n)


10 strncat()

copies given number of characters of one string to another

11 strncpy() char * strncpy ( char * destination, const char * source, size_t num )

last occurrence of given character in a string is found

char *strrchr(char *str, int ch)


12 strrchr()

reverses the given string

13 strrev() char *strrev(char *string)

sets all character in a string to given character

14 strset() char *strset(char *string, int c)

converts string to uppercase

15 strupr() char *strupr(char *string)

tokenizing given string using delimiter

16 strtok() char *strtok(char *str, const char *delim)

It is used to initialize a specified number of bytes to null or any other value in the buffer

17 memset() void *memset(void *str, int c, size_t n)

It is used to copy a specified number of bytes from one memory to another

18 memcpy() void *memcpy(void *dest, const void *src, size_t n)

It is used to copy a specified number of bytes from one memory to another or to overlap
on same memory.

19 memmove() void *memmove(void *dest, const void *src, size_t n)

It is used to compare specified number of characters from two buffers

20 memcmp() int memcmp(const void *str1, const void *str2, size_t n)

It is used to compare specified number of characters from two buffers regardless of the
21 memicmp() case of the characters

It is used to locate the first occurrence of the character in the specified string

22 memchr() void *memchr(const void *str, int c, size_t n)

C – stdlib.h library functions

LIST OF INBUILT C FUNCTIONS IN STDLIB.H FILE:

S.no Function Description

This function is used to allocate space in memory during the execution of the
program.

1 malloc() void*malloc(size_t size)


Monceda, Catherine H. BSCE-2 ES201
This function is also like malloc () function. But calloc () initializes the allocated memory to zero. But,
malloc() doesn’t

2 calloc() void*calloc(size_t nitems,size_t size)

This function modifies the allocated memory size by malloc () and calloc ()
functions to new size

3 realloc() void*realloc(void*ptr,size_t size)

This function frees the allocated memory by malloc (), calloc (), realloc () functions and returns the
memory to the system.

4 free() voidfree(void*ptr)

This function returns the absolute value of an integer . The absolute value of a number is always
positive. Only integer values are supported in C.

5 abs() intabs(int x)

This function performs division operation

6 div() div_tdiv(int numer,int denom)

It terminates the C program

7 abort() voidabort(void)

This function terminates the program and does not return any value

8 exit() voidexit(int status)

This function is used to execute commands outside the C program.

9 system() intsystem(constchar*command)

Converts string to int

10 atoi() intatoi(constchar*str)

Converts string to long

11 atol() longint atol(constchar*str)

Converts string to float

12 atof() doubleatof(constchar*str)

Converts string to double

13 strtod() doublestrtod(constchar*str,char**endptr)

Converts string to long

14 strtol() longintstrtol(constchar*str,char**endptr,intbase)

This function gets the current value of the environment variable

15 getenv() char*getenv(constchar*name)

This function sets the value for environment variable

16 setenv() int setenv(const char *envname,const char *envval, int overwrite)

This function modifies the value for environment variable

17 putenv() int putenv(char *string)

This function displays most recent error that happened during library function call.

18 perror() voidperror(constchar*str)

This function returns the random integer numbers

19 rand() intrand(void)

This function Suspends the execution of the program for particular time

20 delay() void delay(unsigned int)


Monceda, Catherine H. BSCE-2 ES201
C – math.h library functions

LIST OF INBUILT C FUNCTIONS IN MATH.H FILE:

S.no Function Description

This function returns the nearest integer which is less than or equal to the argument passed to this
function.

1 floor ( ) double floor ( double x );

This function returns the nearest integer value of the float/double/long double argument passed to
this function. If decimal value is from “.1 to .5”, it returns integer value less than the argument. If
decimal value is from “.6 to .9”, it returns the integer value greater than the argument.

double round (double a);

float roundf (float a);


round
2 () long double roundl (long double a);

This function returns nearest integer value which is greater than or equal to the argument passed to
this function.

3 ceil ( ) double ceil (double x);

This function is used to calculate sine value.

4 sin ( ) double sin(double x)

This function is used to calculate cosine.

5 cos ( ) double cos(double x)

This function is used to calculate hyperbolic cosine.

6 cosh ( ) double cos(double x)

This function is used to calculate the exponential “e” to the xth power.

7 exp ( ) double exp(double x)

This function is used to calculate tangent.

8 tan ( ) double atan(double x)

This function is used to calculate hyperbolic tangent.

9 tanh ( ) double tanh(double x)

This function is used to calculate hyperbolic sine.

10 sinh ( ) double sinh(double x)

This function is used to calculates natural logarithm.

11 log ( ) double log(double x)

This function is used to calculates base 10 logarithm.

12 log10 ( ) double log10(double x)

This function is used to find square root of the argument passed to this function.

13 sqrt ( ) double sqrt (double x);

This is used to find the power of the given number.

14 pow ( ) double pow (double base, double exponent);

15 trunc.(.) This function truncates the decimal value from floating point value and returns integer value.
Monceda, Catherine H. BSCE-2 ES201
double trunc (double a);

float truncf (float a);

long double truncl (long double a);

C – time.h library functions

LIST OF INBUILT C FUNCTIONS IN TIME.H FILE:

S.no Functions Description

This function used to modify the system date

1 setdate() structtimesetdate(structtime);

This function is used to get the CPU time


2 getdate()
struct tm *getdate(const char *string);

This function is used to get current system time

3 clock() clock_t clock(void)

This function is used to get current system time as structure

4 time() char *ctime(const time_t *timer)

This function is used to get the difference between two given times

5 difftime() double difftime(time_t time1, time_t time2)

This function is used to modify the actual time format

6 strftime() size_t strftime(char *str, size_t maxsize, const char *format, const struct tm *timeptr)

This function interprets tm structure as calendar time

7 mktime() time_t mktime(struct tm *timeptr)

This function shares the tm structure that contains date and time informations

8 localtime() struct tm *localtime(const time_t *timer)

This function shares the tm structure that contains date and time informations

9 gmtime() struct tm *gmtime(const time_t *timer)

This function is used to return string that contains date and time informations

10 ctime() char *ctime(const time_t *timer)

Tm structure contents are interpreted by this function as calendar time. This time is converted into
string.

11 asctime() char *asctime(const struct tm *timeptr)

C – ctype.h library functions

LIST OF INBUILT C FUNCTIONS IN CTYPE.H FILE:.


1.isalpha( ) function in C language checks whether given character is alphabetic or not. Syntax for isalpha( ) function is given
below.
int isalpha ( int x );

2.isdigit( ) function in C language checks whether given character is digit or not. Syntax for isdigit( ) function is given below.int
isdigit ( int x );

3.isalnum() function in C language checks whether given character is alphanumeric or not. Syntax for isalnum( ) function is given
below.
int isalnum ( int x );

4.isspace( ) function in C language checks whether given character is space or not. Syntax for isspace( ) function is given below.
int isspace( int x );
Monceda, Catherine H. BSCE-2 ES201
5.islower( ) function in C language checks whether given character is lower case or not. Syntax for islower( ) function is given
below.
int islower( int x );

6.isupper( ) function in C language checks whether given character is upper case or not. Syntax for isupper( ) function is given
below.
int isupper ( int x )

7.isxdigit( ) function in C language checks whether given character is hexadecimal or not. Syntax for isxdigit( ) function is given
below.
int isxdigit( int x );

8. isprint( ) function in C language checks whether given character is printable character or not. Syntax for isprint( ) function is
given below.
int isprint( int x );

9.iscntrl( ) function in C language checks whether given character is control character or not. Syntax for iscntrl( ) function is given
below.
int iscntrl( int x );

10.ispunct( ) function in C language checks whether given character is punctuation or not. Syntax for ispunct( ) function is given
below.
int ispunct( int x );

11.isgraph( ) function in C language checks whether given character is graphical character or not. Syntax for isgraph( ) function is
given below.
int isgraph( int x );

12.tolower( ) function in C language checks whether given character is alphabetic and converts to lowercase. Syntax for tolower( )
function is given below.
int tolower( int x );

13.toupper( ) function in C language checks whether given character is alphabetic and converts to uppercase. Syntax for toupper( )
function is given below.
int toupper( int x )

C – All other library functions

LIST OF ALL OTHER INBUILT FUNCTIONS IN C:

S.no Header_file Function Description

This function indicates the start process of variable length argument list in a
program

va_start() void va_start(va_list ap, last_arg)

This function is used to fetch the arguments from variable length argument list

va_arg() type va_arg(va_list ap, type)

This function indicates the end process of variable length argument list in a
program

1 stdarg.h va_end() void va_end(va_list ap)

It is used to install signal handler

signal() void (*signal(int sig, void (*func)(int)))(int)

It is used to raise signal in a C program

2 signal.h raise() int raise(int sig)

This function prepares to use longjmp() function

setjmp() int setjmp(jmp_buf environment)

It is used for non local jump

3 setjmp.h longjmp() void longjmp(jmp_buf environment,int value)


Monceda, Catherine H. BSCE-2 ES201
It sets locale()

setlocale() char *setlocale(int category, const char *locale)

It gets locale conventions

4 locale.h localeconv() struct lconv *localeconv(void)

This function sets errno value to 0 at the beginning of the program. This value
is modified to other than 0 when an error occurs while any function call.

5 errno.h errno() extern int errno

This function gets an integer as paramenter. If this paramenter is 0, writes


message
to stderr. Then, terminates the program. If this paramenter is non 0, it does
nothing.

6 assert.h assert() void assert(int expression)

Вам также может понравиться