Why memory functions such as memset, memchr… are in string.h, but not in stdlib.h with another mem functions?

前端 未结 4 1313
独厮守ぢ
独厮守ぢ 2021-01-30 16:01

I wonder, why such function as:
-memset
-memmov
-memchr
-memcpy

Exist in string.h header file, but not in stdlib.h file, where there are ot

4条回答
  •  渐次进展
    2021-01-30 16:51

    Because actually string.h is defined as a standard header that declares functions that treat array of characters and not only strings. Functions like memcpy and memset take arguments that are treated as pointers to the first element of an object of type array of characters.

    (C99, 7.21.1p1) The header < string.h > declares one type and several functions, and defines one macro useful for manipulating arrays of character type and other objects treated as arrays of character type.

提交回复
热议问题