Home  >  Q&A  >  body text

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

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

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

reply all(1)I'll reply

  • 阿神

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

    These two member functions are designed to be compatible with the Cinterface .

    reply
    0
  • Cancelreply