首页  >  问答  >  正文

c++ - 请教下 string::data 或 string::c_str的应用方向?

在 c++11里面这倆已经变得一样了. 不过我不是很理解这个函数在除了这个稍显鸡肋情况下还有哪里可以用到.

string s = "Hello, world!";
printf("%s", s.c_str());
黄舟黄舟2714 天前795

全部回复(1)我来回复

  • 阿神

    阿神2017-04-17 15:25:39

    这两个成员函数就是为了兼容C接口而设计的。

    回复
    0
  • 取消回复