DEV Community

Cover image for Useful Header files in C
hebaShakeel
hebaShakeel

Posted on • Edited on

6 1

Useful Header files in C

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!

Heroku

Built for developers, by developers.

Whether you're building a simple prototype or a business-critical product, Heroku's fully-managed platform gives you the simplest path to delivering apps quickly — using the tools and languages you already love!

Learn More

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Dive into this informative piece, backed by our vibrant DEV Community

Whether you’re a novice or a pro, your perspective enriches our collective insight.

A simple “thank you” can lift someone’s spirits—share your gratitude in the comments!

On DEV, the power of shared knowledge paves a smoother path and tightens our community ties. Found value here? A quick thanks to the author makes a big impact.

Okay