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>
?
<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.
Apparently cstring is for C++ and string. h is for C. One thing worth mentioning is, if you are switching from string. h to cstring , remember to add std:: before all your string function calls.
h is the header in the C standard library for the C programming language which contains macro definitions, constants and declarations of functions and types used not only for string handling but also various memory handling functions; the name is thus something of a misnomer. Functions declared in string.
h is the header file required for string functions. This function appends not more than n characters from the string pointed to by src to the end of the string pointed to by dest plus a terminating Null-character.
<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.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With