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