<string.h> v.s. <string>
string.h
contains old functions like strcpy
, strlen
,
string
primiraly contains std::string
class.
It should also be noted that using string.h
is deprecated within C++. If you need the functionality contained within, you should use the header cstring
. This more or less completely bypasses the issue of "What's the difference between these two" because it's very obvious that one is from the C library. – Mike Bantegui
<cstring> v.s. <string>
http://www.cplusplus.com/forum/general/38801/
“<cstring> is basically a header containing a set of functions for dealing with C-style strings (char*). <string>, on the other hand, is header that allows you to use C++-style strings (std::string), which can do a lot of if not all of the functions provided in <cstring> on their own. - Albatross“
Use string. cstring is so 1970's. string is a modern way to represent strings in c++. you'll need to learn cstring because you will run into code that uses it. but cstring is responsible for lots of unsafe code. - PanGalactic“
http://stackoverflow.com/a/12824665
<strings.h> v.s <string.h>
http://stackoverflow.com/a/4291176
Typically <strings.h>
just adds some useful but non-standard additional string functions to the standard header <string.h>
. For maximum portability you should only use <string.h>
but if you need the functions in <strings.h>
more than you need portability then you can use <strings.h>
instead of <string.h>
.
No comments:
Post a Comment