[英]include string or string.h
To use memset(), what is the difference between 要使用memset(),有什么区别
#include <string> //did not work
and 和
#include <string.h> //worked
Thanks! 谢谢!
<string>
is a C++ standard library include, and <string.h>
is C standard library include. <string>
是一个C ++标准库包含,而<string.h>
是C标准库包含。
The equivalent of <string.h>
in C++ is <cstring>
, although both will work. C ++中
<string.h>
的等价物是<cstring>
,尽管两者都有效。
The difference is: <cstring>
wraps everything in the std
namespace whereas <string.h>
puts everything in the global namespace. 区别在于:
<cstring>
包装std
命名空间中的所有内容,而<string.h>
将所有内容放在全局命名空间中。
Also, expect some stricter type safety rules from <cstring>
. 此外,期望
<cstring>
有一些更严格的类型安全规则。
在现代C ++环境中,您需要#include <cstring>
来获取memset()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.