要使用memset(),有什么区别
#include <string> //did not work
Run Code Online (Sandbox Code Playgroud)
和
#include <string.h> //worked
Run Code Online (Sandbox Code Playgroud)
谢谢!
Rus*_*hPL 30
<string>是一个C++标准库包含,并且<string.h>是C标准库包含的.
相当于<string.h>C++ <cstring>,虽然两者都有效.
区别在于:<cstring>将所有内容包装在std命名空间中,而<string.h>将所有内容放在全局命名空间中.
此外,期待一些更严格的类型安全规则<cstring>.
在现代的C++环境中,你会#include <cstring>得到memset().