C++标准输出cout与printf都可以,printf用法更死板一些。

#include <iostream>

int main(int argc, char** argv) {
using namespace std;
#普通输出
cout<<"This is cout"<<endl;
printf("This is printf\n");

    #如果要输出字符串,则printf记得加上c_str(),把std:string转成const char*
string mystring=&quot;my_defined_string&quot;;
cout&lt;&lt;mystring&lt;&lt;endl;
printf(&quot;This is printf: %s&quot;,mystring.c_str());
return 0;

}

相关文章:

  • 2022-01-02
  • 2020-10-21
  • 2022-12-23
  • 2021-11-05
  • 2022-12-23
  • 2021-09-29
猜你喜欢
  • 2021-12-02
  • 2022-12-23
  • 2021-10-16
相关资源
相似解决方案