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

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

Nov 7, 2017 at 9:11pm
I couldn't find cstring methods on that page.
Seems misleading since strlen() does not work with cstring, one must use
x.length() instead.
Nov 7, 2017 at 9:37pm
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 Nov 7, 2017 at 9:38pm
Nov 8, 2017 at 12:16am
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.
Topic archived. No new replies allowed.