<string> 之间的区别和<string.h>? [英] Difference between <string> and <string.h>?

查看:21
本文介绍了<string> 之间的区别和<string.h>?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这段代码怎么来的

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

编译(我使用的是 MSVC 2010)

compiles with (I'm using MSVC 2010)

#include <string>

但没有

#include <string.h>

?

推荐答案

  • <string.h> 包含旧函数,如 strcpystrlen 用于 C 风格的空终止字符串.
  • <string>主要包含std::stringstd::wstring等类.
    • <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.
    • 这篇关于&lt;string&gt; 之间的区别和&lt;string.h&gt;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆