码迷,mamicode.com
首页 > 其他好文 > 详细

string::data

时间:2019-12-24 09:19:02      阅读:60      评论:0      收藏:0      [点我收藏+]

标签:stream   clu   The   ret   content   main   except   std   out   

const char* data() const noexcept;
注:同c_str

#include <iostream>
#include <string>
#include <cstring>
using namespace std;
int main()
{
string s1("hellolyy");
const char *cstr = "hellolyy";
if(s1.length() == strlen(cstr))
{
cout << "the same length\n";
if(memcmp(cstr, s1.data(), s1.length()) == 0)
cout << "the same content\n";
}
return 0;
}

string::data

标签:stream   clu   The   ret   content   main   except   std   out   

原文地址:https://www.cnblogs.com/xpylovely/p/12089582.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!