In C programming, what standard library header contains the strcpy function?

The story behind the answer

In C programming, the standard library header containing `strcpy` is `<string.h>`.

The `strcpy` function copies a null-terminated byte string from a source array to a destination array, including the terminating null character. Programs normally make its declaration available with `#include <string.h>`, which also provides declarations for related string and memory functions such as `strlen`, `strcmp`, `strcat`, and `memcpy`.

The other choices belong to different areas of the library. `<math.h>` declares mathematical functions, `<stdlib.h>` covers utilities such as memory allocation and numeric conversion, and `<stdio.h>` handles input and output. None of those headers is the standard home of `strcpy`.

A major practical warning is that `strcpy` does not check whether the destination has enough space. If the source string, including its null terminator, will not fit, copying can overwrite memory and cause undefined behavior. Safer designs track buffer sizes explicitly, though even alternatives require careful handling of termination and truncation.

Source: Wikipedia · fact-checked Sept. 2026

Add question to a list

Choose a list to keep this question in: