search

Home  >  Q&A  >  body text

C++ printf问题

我们都知道c++都使用cout输出的,但也可以使用printf;

printf("字符串:\n 字符串1:%s\n 字符串2:%s\n 字符串3:%s\n",str1,str2,str3);

VC6编译通过,但是不能运行,一运行就出现结束运行停止,被强制关闭;

我尝试使用gcc编译;
string类怎么了?不能使用

大家讲道理大家讲道理2805 days ago615

reply all(1)I'll reply

  • ringa_lee

    ringa_lee2017-04-17 11:04:11

    If you want to printf a string, you have to use it this way, otherwise it will definitely be coredump, VC6 is too old and should not be used

    string str;
    printf("%s", str.c_str());

    reply
    0
  • Cancelreply