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

Valmond picture Valmond · Feb 13, 2012 · Viewed 53.2k times · Source

How come this code

std::map <std::string , int> m;
m["a"]=1;

compiles with (I'm using MSVC 2010)

#include <string>

but not with

#include <string.h>

?

Answer

Ajay picture Ajay · Feb 13, 2012
  • <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.