What is string.h and why do we use?

Last Updated :

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.

Comment
Next Article
Mithlesh Upadhyay Published 19 May, 2023 · 1 min read

Mithlesh Upadhyay is a Computer Science and AI expert from Madhya Pradesh with strong academic background (BE in CSE and M.Tech in AI) and over six years of experience in technical content development. He has contributed tech articles, led teams, and worked in Full Stack Development and Data Science. He founded the w3colleges.org portal for learning resources.

Article Tags :

Similar Reads

  • Four Pillars of Object-Oriented Programming (OOPS)

    Get an overview of four pillars of object-oriented programming (OOP) and see their suitable real life examples. What is OOP? Picture a cluttered garage🛠️. Tools are scattered everywhere,…

    4 min read
  • What is Overriding in C++

    Write a program in C++ to depict the concept of overriding or Dynamic polymorphism. Overriding is a type of polymorphism. Polymorphism in OOP languages means to take more…

    2 min read
  • What should we use void main() or int main() ?

    There is question that what should we use void main() or int main() ? void main() { /* ... */ } Or, int main() { /* ... */…

    2 min read
  • C Comments

    Prerequisite – C Language Introduction C comments explain code and improve readability. These do not affect program execution. You can use comments in C to clarify code and describe…

    1 min read
  • C Programming Language Standard

    Prerequisite – C Language Introduction The C programming language has various versions: C89/C90, C99, C11, and C18. C89/C90: Released in 1989/1990. It introduced key language features. C99: This…

    2 min read
  • Features of C Programming Language

    Prerequisite – C Language Introduction C is a simple language made in 1972 by Dennis Ritchie. It’s for system programming. C has low-level memory access, basic keywords, good…

    1 min read