Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

To use memset(), what is the difference between

#include <string>       //did not work

and

#include <string.h>     //worked

Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
222 views
Welcome To Ask or Share your Answers For Others

1 Answer

<string> is a C++ standard library include, and <string.h> is C standard library include.

The equivalent of <string.h> in C++ is <cstring>, although both will work.

The difference is: <cstring> wraps everything in the std namespace whereas <string.h> puts everything in the global namespace.

Also, expect some stricter type safety rules from <cstring>.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...