Difference between <string> and <string.h>?

  • <string.h> contains old functions like strcpy, strlen for C style null-terminated strings.
  • <string> primarily contains the std::string, std::wstring and other classes.

string.h is a C header not a C++ header, period!


<string.h> is cstring - http://www.cplusplus.com/reference/clibrary/cstring/

<string> is the c++ string class - http://www.cplusplus.com/reference/string/

Edit per Nicol Bolas comment below and a bit of googling:

<cstring> will usually import the same things as <string.h> but into the std namespace. <string.h> will usually import everything into the global namespace. It appears to depend on the library implementation you're using though according to my googling.

Personally I only ever use <cstring> if I need C style string helpers.