为什么存储功能,例如memset的,了memchr ...是string.h中,但不与另一种纪念品功能stdlib.h中? [英] Why memory functions such as memset, memchr... are in string.h, but not in stdlib.h with another mem functions?

查看:109
本文介绍了为什么存储功能,例如memset的,了memchr ...是string.h中,但不与另一种纪念品功能stdlib.h中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道,为什么这样的功能:

-memset

-memmov

-memchr

-memcpy

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

存在string.h中的头文件,但不是在stdlib.h中的文件,这里是另一种非标准存储功能动态内存分配:malloc的,释放calloc,realloc的,免费

Exist in string.h header file, but not in stdlib.h file, where are another standart memory functions as dynamic memory allocation: malloc, calloc, realloc, free.

也许这将是更好地团结他们一个头?你怎么看待这件事?
我不明白,为什么一个存储功能从anothers分离,并在字符串头(string.h中)存在。

Maybe it would be better to unite them in one header? What do you think about it? I don't understand, why one memory functions are separated from anothers and exist in string header ( string.h ).

推荐答案

由于实际文件string.h 被定义为宣称把字符数组功能一个标准的头和不仅字符串。像功能的memcpy memset的采取被视为指向字符类型的数组对象的第一个元素参数

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)头< string.h>的声明一种类型和多种功能,并限定一个宏有用用于操纵作为阵列处理字符类型和其它目的的阵列
  的字符类型。

(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.

这篇关于为什么存储功能,例如memset的,了memchr ...是string.h中,但不与另一种纪念品功能stdlib.h中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆