• Forum
  • Lounge
  • Shouldn't cstring and string.h have sepa

 
Shouldn't cstring and string.h have separate pages?

I couldn't find cstring methods on that page.
Seems misleading since strlen() does not work with cstring, one must use
x.length() instead.
Seems misleading since strlen() does not work with cstring, one must use
x.length() instead.

No strlen() requires a C-string while x.length() would require a std::string. The <cstring> header defines functions used to operate on C-strings, while <string> defines the C++ string class.

Also the <string.h> include is the C standard header and <cstring> is the C++ standard header that provides the same functions as <string.h>
Last edited on
Oh, yes. I see now.
My mistake was just that, using <cstring> thinking that was the header for c++ strings.
Should have used <string>.
thank you.
Registered users can post here. Sign in or register to post.