

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Header files “stdio.h” and “stdlib.h” in C
stdio.h
The header file stdio.h stands for Standard Input Output. It has the information related to input/output functions.
Here is the table that displays some of the functions in stdio.h in C language,
Sr.No. | Functions & Description |
---|---|
1 | printf() It is used to print the strings, integer, character etc on the output screen. |
2 | scanf() It reads the character, string, integer etc from the keyboard. |
3 | getc() It reads the character from the file. |
4 | putc() It writes the character to the file. |
5 | fopen() It opens the file and all file handling functions are defined in stdio.h header file. |
6 | fclose() It closes the opened file. |
7 | remove() It deletes the file. |
8 | fflush() It flushes the file. |
Here is an example of stdio.h in C language,
Example
#include<stdio.h> int main () { char val; printf("Enter the character: \n"); val = getc(stdin); printf("Character entered: "); putc(val, stdout); return(0); }
Output
Here is the output
Enter the character: s Character entered: s
stdlib.h
The header file stdlib.h stands for Standard Library. It has the information of memory allocation/freeing functions.
Here is the table that displays some of the functions in stdlib.h in C language,
Sr.No. | Functions & Description |
---|---|
1 | malloc() It allocates the memory during execution of program. |
2 | free() It frees the allocated memory. |
3 | abort() It terminates the C program. |
4 | exit() It terminates the program and does not return any value. |
5 | atol() It converts a string to long int. |
6 | atoll() It converts a string to long long int. |
7 | atof() It converts a string to floating point value. |
8 | rand() It returns a random integer value |
Here is an example of stdlib.h in C language,
Example
#include <stdio.h> #include<stdlib.h> int main() { char str1[20] = "53875"; char str2[20] = "367587938"; char str3[20] = "53875.8843"; long int a = atol(str1); printf("String to long int : %d\n", a); long long int b = atoll(str2); printf("String to long long int : %d\n", b); double c = atof(str3); printf("String to long int : %f\n", c); printf("The first random value : %d\n", rand()); printf("The second random value : %d", rand()); return 0; }
Output
Here is the output
String to long int : 53875 String to long long int : 367587938 String to long int : 53875.884300 The first random value : 1804289383 The second random value : 846930886
- Related Questions & Answers
- Print “Hello World” in C/C++ without using header files
- Python Object Comparison “is” vs “==”
- Why avoid increment (“++”) and decrement (“--”) operators in JavaScript?
- Difference between “int main()” and “int main(void)” in C/C++?
- Using combination of “AND” and “OR” in SELECT in ABAP
- Deletions of “01” or “10” in binary string to make it free from “01” or “10” in C++ Program
- Explain import “as” and Export “as” constructs in JavaScript.
- “extern” keyword in C
- “register” keyword in C
- “volatile” qualifier in C
- Inline conditions in Lua (a == b ? “yes” : “no”)
- HTML5 <input type=“file” accept=“image/*” capture=“camera”> display as image rather than “choose file” button
- Deletions of “01” or “10” in binary string to make it free from “01” or “10" in C++?
- Print “Hello World” without using any header file in C
- How to replace “and” in a string with “&” in R?
Advertisements