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.
Please do Like/Tweet/G+1 if you find the above useful. Also, please do leave us comment for further clarification or info. We would love to help and learn 🙂
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
Recommended Posts:
- Header files in C/C++ with Examples
- Difference between Header file and Library
- accumulate() and partial_sum() in C++ STL : numeric header
- numeric header in C++ STL | Set 2 (adjacent_difference(), inner_product() and iota())
- Namespace in C++ | Set 3 (Accessing, creating header, nesting and aliasing)
- Print "Hello World" in C/C++ without using any header file
- Comment in header file name?
- How to write your own header file in C?
- clocale header file in C++
- time.h header file in C with Examples
- <complex.h> header file in C with Examples
- dos.h header in C with examples
- C Program to list all files and sub-directories in a directory
- C program to compare two files and report mismatches
- C Program to merge contents of two files into a third file
- Linking Files having same variables with different data types in C
- Types of C files after its compilation
- Difference between Stop and Wait protocol and Sliding Window protocol
- Similarities and Difference between Java and C++
- Difference between Yaacomo and and XAP

