< string>和< string.h>? [英] Difference between <string> and <string.h>?

查看:144
本文介绍了< 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> 包含 strcpy strlen 用于C样式以null结尾的字符串。 code> std :: 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天全站免登陆