In the C programming language, what is the name of the standard library header for string functions?

The story behind the answer

In the C programming language, the standard library header for string functions is string.h.

A C program typically includes it with the directive #include <string.h>. The header provides declarations for familiar functions such as strlen() for measuring a string, strcpy() for copying one, strcat() for joining strings, and strcmp() for comparing them. It also declares memory-oriented functions such as memcpy() and memset().

C does not have a built-in string type. Instead, a C string is usually an array of characters ending with a null character, written '\0'. Functions in string.h rely on that terminator to know where a string ends. If it is missing, functions such as strlen() may read beyond the intended array, causing incorrect results or a memory-safety vulnerability.

A common mix-up is stdio.h, which handles input and output, including printf(). stdlib.h contains general utilities such as memory allocation and numeric conversion, while math.h declares mathematical functions. In C++, the related header is commonly accessed through <cstring>, although the underlying C library facilities remain closely connected to string.h.

Source: Wikipedia · fact-checked Aug. 2026

Add question to a list

Choose a list to keep this question in: