DEV Community

loading...
Cover image for Useful Header files in C

Useful Header files in C

hebashakeel profile image hebaShakeel Updated on ・2 min read

What are Header Files?

A header file is a file with extension .h which contains C function declarations and macro definitions to be shared between several source files.

Some commonly used header files in C language are:

stdio.h:

Facilitates input output statements

conio.h:

Facilitates console input/output functions

string.h:

Contains macro definitions, constants and declarations of functions and types
-> strlen(): length of the char array
-> strcpy(): copies a string to another
-> strcat(): concatenates two strings
-> strcmp(): compares two strings
-> strlwr(): converts from upper case to lower case
-> strupr(): converts from lower case to upper case
-> strrev(): reverses a string

ctype.h:

Contains functions that would facilitate manipulation of character data type. The functions supported are:

-> isalnum(): Checks whether a character is alphanumeric(A-Z,a-z,0-9)
-> isalpha(): Checks whether a character i alphabetic
-> islower(), isupper(): Test if character is lower or upper respectively.
-> tolower(), toupper(): Converts to lower and upper cases

math.h:

Contains library functions. Note that x can be a float or double. C language does not support expression of type x^a.

-> sqrt(x): determines square root of x
-> pow(x,a): compute x^a
-> exp(x): computes e^x
-> sin(x) and cos(x): computes sine and cosine
-> log(x): computes natural log
-> log10(x): computes log to base 10.

stdlib.h:

-> abs(x): computes absolute value of integer x
-> atof(s): converts a string s to a double
-> atoi(s): converts to integer
-> malloc(): allocates memory and returns a pointer to the location
-> calloc(): same as malloc() but initializes the memory with 0s.
-> free(x): frees heap memory space pointed by x.

Cover Photo by Aryan Singh on Unsplash
Thank You!

Discussion

pic
Editor guide