Heim  >  Fragen und Antworten  >  Hauptteil

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

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

string s = "Hello, world!";
printf("%s", s.c_str());
黄舟黄舟2714 Tage vor794

Antworte allen(1)Ich werde antworten

  • 阿神

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

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

    Antwort
    0
  • StornierenAntwort