C/C++ PROGRAMMING
HEADER FILES COMMONLY AND FREQUENTLY USED IN C/C++ PROGRAMMING
In C programming, header files contain function declarations, macros, and definitions that can
be used in multiple programs. Below are some commonly used header files along with the most
frequently used functions under them:
1. <stdio.h> (Standard Input/Output)
printf() – Print formatted output.
scanf() – Read formatted input.
gets() / fgets() – Read a string (avoid gets() as it's unsafe).
puts() – Print a string.
putchar() / getchar() – Print/read a single character.
fopen(), fclose(), fread(), fwrite() – File handling functions.
2. <stdlib.h> (Standard Library)
malloc(), calloc(), realloc(), free() – Dynamic memory management.
atoi(), atof(), atol() – Convert strings to numbers.
exit() – Terminate a program.
rand(), srand() – Generate random numbers.
3. <string.h> (String Handling)
strcpy(), strncpy() – Copy strings.
strcat(), strncat() – Concatenate strings.
strlen() – Get string length.
strcmp(), strncmp() – Compare strings.
strchr(), strrchr() – Find characters in a string.
4. <math.h> (Mathematical Functions)
pow() – Exponential power.
sqrt() – Square root.
ceil(), floor() – Rounding functions.
fabs() – Absolute value.
sin(), cos(), tan() – Trigonometric functions.
5. <ctype.h> (Character Handling)
isalpha(), isdigit() – Check if character is alphabetic or numeric.
toupper(), tolower() – Convert case.
isspace(), ispunct() – Check for spaces or punctuation.
6. <time.h> (Time Handling)
time() – Get current time.
clock() – CPU time used.
difftime() – Time difference.
strftime() – Format date/time.
7. <conio.h> (Console Input/Output, non-standard)
clrscr() – Clear screen (non-standard).
getch(), getche() – Get character input without/with echo.
textcolor(), textbackground() – Change text colors.
Would you like details on any specific header file?