The C Standard Library contains a vast array of functions categorized into various headers, each serving different purposes. Below is a list of some commonly used Standard Library headers and a brief overview of their primary functions. Please note that this list is not exhaustive, as there are many more functions and headers available for various purposes.
stdio.h (Standard Input/Output):
printf(): Print formatted output to the console.scanf(): Read formatted input from the console.fopen(),fclose(),fread(),fwrite(): File I/O operations.getchar(),putchar(): Read and write characters.
stdlib.h (Standard Library):
malloc(),calloc(),realloc(),free(): Dynamic memory allocation and deallocation.rand(),srand(): Generate random numbers.exit(): Terminate program execution.
string.h (String Manipulation):
strcpy(),strncpy(): Copy strings.strcmp(),strncmp(): Compare strings.strlen(): Calculate string length.strcat(),strncat(): Concatenate strings.strstr(): Find substring in a string.
math.h (Mathematical Functions):
sqrt(),pow(),exp(),log(): Mathematical operations.sin(),cos(),tan(): Trigonometric functions.ceil(),floor(): Round numbers up or down.rand(),srand(): Random number generation.
ctype.h (Character Handling):
isalpha(),isdigit(),islower(),isupper(): Character classification.tolower(),toupper(): Convert characters to lowercase or uppercase.
time.h (Date and Time):
time(): Get current time.ctime(): Convert time to a string.difftime(): Calculate time differences.strftime(): Format time as a string.
stddef.h (Standard Definitions):
NULL: Null pointer constant.size_t: Unsigned integer type used for sizes.
stdbool.h (Boolean Type):
bool: Boolean data type (true or false).
assert.h (Assertions):
assert(): Debugging aid to check program assumptions.
stdarg.h (Variable Argument Lists):
va_start(),va_arg(),va_end(): Handle functions with a variable number of arguments (e.g.,printf()).signal.h (Signal Handling):
signal(): Set signal-handling functions.raise(): Raise signals in the program.
locale.h (Locale and Internationalization):
setlocale(): Set the program's locale.- Functions for handling character encoding and internationalization.
errno.h (Error Handling):
errno: Global variable containing error codes.- Functions like
perror()to handle errors gracefully.
stddef.h (Standard Definitions):
NULL: Null pointer constant.size_t: Unsigned integer type used for sizes.
fcntl.h (File Control):
open(),close(),read(),write(): File I/O operations with low-level control.
sys/types.h and sys/stat.h (System Types and System Stat):
- Data types and functions for dealing with system-related information and file attributes.
unistd.h (POSIX Operating System API):
- Functions for interacting with the operating system, including process control and file operations.
math.h (Mathematical Functions):
fmod(),log10(),sinh(),cosh(),tanh(): Additional mathematical functions.
These are just some of the commonly used functions and headers from the C Standard Library. Each header contains a set of functions tailored to specific tasks, making C a versatile language for various programming needs. To utilize these functions, you typically include the relevant header at the beginning of your C source code file
Follow us