The Wayback Machine - https://web.archive.org/web/20240717024340/https://www.geeksforgeeks.org/whats-difference-between-and/
Open In App

What’s difference between header files “stdio.h” and “stdlib.h” ?

Last Updated : 30 Oct, 2023
Improve
Suggest changes
Post a comment
Like Article
Like
Save
Share
Report

These are two important header files used in C programming. While “<stdio.h>” is header file for Standard Input Output, “<stdlib.h>” is header file for Standard Library. One easy way to differentiate these two header files is that “<stdio.h>” contains declaration of printf() and scanf() while “<stdlib.h>” contains declaration of malloc() and free(). In that sense, the main difference in these two header files can considered that, while “<stdio.h>” contains header information for ‘File related Input/Output’ functions, “<stdlib.h>” contains header information for ‘Memory Allocation/Freeing’ functions.

Wait a minute, you said “<stdio.h>” is for file-related IO but printf() and scanf() don’t deal with files… or are they? As  a basic principle, in C (due to its association with UNIX history), keyboard and display are also treated as ‘files’! In fact keyboard input is the default stdin file stream while display output is the default stdout file stream. Also, please note that, though “<stdlib.h>” contains declaration of other types of functions as well that aren’t related to memory such as atoi(), exit(), rand() etc. yet for our purpose and simplicity, we can remember malloc() and free() for “<stdlib.h>”.

It should be noted that a header file can contain not only function declaration but definition of constants and variables as well. Even macros and definition of new data types can also be added in a header file.

Differences between stdio.h and stdlib.h :

 

stdio.h

stdlib.h

1. stdio.h stands for Standard Input Output stdlib.h stands for Standard Library.
2. It has information related to input/output functions. It has information related to memory allocation/free functions.
3. Some of the functions in stdio.h are printf, scanf ,getc, putc , etc Some of the functions in stdlib.h are malloc ,  free ,abort , exit ,etc.
4. stdio.h is used by almost every C program. stdlib.h is only use when we need to allocate memory in our program.

Previous Article
Next Article

Similar Reads

Header Files in C
In C language, header files contain a set of predefined standard library functions. The .h is the extension of the header files in C and we request to use a header file in our program by including it with the C preprocessing directive "#include". C Header files offer the features like library functions, data types, macros, etc by importing them int
7 min read
Header Files in C++
C++ offers its users a variety of functions, one of which is included in header files. In C++, all the header files may or may not end with the ".h" extension unlike in C, Where all the header files must necessarily end with the ".h" extension. Header files in C++ are basically used to declare an interface of a module or any library. A header file
6 min read
Difference between Header file and Library
Header Files: The files that tell the compiler how to call some functionality (without knowing how the functionality actually works) are called header files. They contain the function prototypes. They also contain Data types and constants used with the libraries. We use #include to use these header files in programs. These files end with .h extensi
3 min read
Difference Between Sequential, Indexed, and Relative Files in COBOL
Files are the collection of records related to a particular entity. Through file handling, we can store these records in an organized order. These records are stored either on magnetic tape or on a hard disk. The files are further classified into 3 types: Sequential file organization.Relative file organization.Indexed file organization.Advantages o
5 min read
What Is The Difference Between .Py And .Pyc Files?
When working with Python, you might have come across different file extensions like .py and .pyc. Understanding the differences between these two types of files is essential for efficient Python programming and debugging. '.py' files contain human-readable source code written by developers, while '.pyc' files are compiled bytecode generated by the
3 min read
accumulate() and partial_sum() in C++ STL : Numeric header
The numeric header is part of the numeric library in C++ STL. This library consists of basic mathematical functions and types, as well as optimized numeric arrays and support for random number generation. Some of the functions in the numeric header: iotaaccumulatereduceinner_productpartial_sum etc. This article explains accumulate() and partial_sum
4 min read
numeric header in C++ STL | Set 2 (adjacent_difference(), inner_product() and iota())
The numeric header is part of the numeric library in C++ STL. This library consists of basic mathematical functions and types, as well as optimized numeric arrays and support for random number generation. Some of the functions in the numeric header: iotaaccumulatereduceinner_productpartial_sum etc. See this article for more reference: accumulate()
4 min read
clocale header file in C++
clocale: This header file contains declaration of a set of functions and a type for internationalization support tasks. It supports date format or country specific currency symbols. For example, date/time formatting, monetary formatting and many more. Methods in clocale header: localeconv(): This function returns an object which represents numeric
2 min read
Comment in header file name?
What happens if there is a comment in header file name? Parsing of `#include' is slightly special because comments are not recognized within the ''. Thus, in `#include ' the `/*' does not start a comment and the directive specifies inclusion of a system header file named `x/*y'. Of course, a header file with such a name is unlikely to exist on Unix
1 min read
Print "Hello World" in C/C++ without using any header file
Write a C/C++ program that prints Hello World without including any header file. Conceptually it's seems impractical to write a C/C++ program that print Hello World without using a header file of "stdio.h". Since the declaration of printf() function contains in the "stdio.h" header file. But we can easily achieve this by taking the advantage of C p
2 min read
three90RightbarBannerImg