Standard Library header file (stdlib.h) in C Programming

‘stdlib’ is an acronym for Standard Library. It is header file of standard library in C which contains the functions like allocation of memory, conversions, process controls and other utilities.

Some of the standard member functions of stdlib.h header files are,

Function Name	Description
abs -		It returns the absolute value of a number.
atof -		It converts string into double value.
atoi -		It converts string into integer value.
atol -		It converts string into long integer value.
abort -		It terminates execution as abnormally.
exit -		It terminates execution of a program.
malloc -	It allocates memory from heap.
realloc -	It reallocates the memory.
calloc -	It allocates specific memory to array of 
                object of sizes.
free -		Releases the memory.
rand -		It creates the series of pseudo numbers.
qsort -		It sorts an array.

Program :

/*  Program to demonstrate stdlib.h header file working.
Creation Date : 06 Nov 2010 03:13:00 AM
Author : [Technowell, Sangli] */

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>

int main(void)
	char no[10];
	printf("\n\t Using abs(-194): %d",abs(-194)); // 1
	printf("\n\n\t Enter any number : ");
	printf("\n\t Using atof() : %lf",atof(no)); // 2
	printf("\n\n\t Using atoi() : %d",atoi(no)); // 3
	return 0;

Output :

	Using abs(-194) : 194

	Enter any number : 12

	Using atof() : 12.000000

	Using atoi() : 12_

Leave A Comment

Your email address will not be published. Required fields are marked *