What is string.h and why do we use?

By | May 19, 2023

The string.h header defines one variable type, one macro, and various functions for manipulating arrays of characters.

#include<string.h>

Functions provided by string.h

The string.h header file declares a set of functions to work strings. To perform operations like comparison, concatenation, and copying, this string.h library is widely used. This header file defines several functions to manipulate C strings and arrays.

  1. Copying – memcpy, memmove, strcpy, strncpy
  2. Concatenation – strcat, strncat
  3. Comparison – memcmp, strcmp, strcoll, strncmp, strxfrm
  4. Searching – memchr, strchr, strcspn, strpbrk, strrchr, strspn, strstr, strtok
  5. Other – memset, strerror, strlen

Note

NULL is macro and size_t is a type used in C provided

  • NULL – Null pointer (macro)
  • size_t – Unsigned integral type (type)

Please write comments if you find anything incorrect. A gentle request to share this topic on your social media profile.

Author: Mithlesh Upadhyay

I hold an M.Tech degree in Artificial Intelligence (2023) from Delhi Technological University (DTU) and possess over 4 years of experience. I worked at GeeksforGeeks, leading teams and managing content, including GATE CS, Test Series, Placements, C, and C++. I've also contributed technical content to companies like MarsDev, Tutorialspoint, StudyTonight, TutorialCup, and Guru99. My skill set includes coding, Data Structures and Algorithms (DSA), and Object-Oriented Programming (OOPs). I'm proficient in C++, Python, JavaScript, HTML, CSS, Bootstrap, React.js, Node.js, MongoDB, Django, and Data Science.