FlyingEgg 发表于 2022-2-23 16:13:12

关于cout的小问题

#include <iostream>
using namespace std;
int main()
{
        int x;
        cin>>x;
        cout<<'x='<<x<<endl;
        return 0;
       
       
}

为什么会有warming   multi character characterconstant
而且数值不对

大马强 发表于 2022-2-23 16:19:49

字符串要用双引号

#include <iostream>
using namespace std;
int main()
{
      int x;
      cin>>x;
      cout<<"x="<<x<<endl;
      return 0;
         
      
}
8
x=8

ba21 发表于 2022-2-23 16:21:41

'x' 字符
"x=" 字符串

isdkz 发表于 2022-2-23 19:36:45

除了 python ,其它的编程语言字符串都需要用双引号

#include <iostream>
using namespace std;
int main()
{
      int x;
      cin>>x;
      cout<<"x="<<x<<endl;   // 把 'x=' 改成 "x="
      return 0;
         
      
}

FlyingEgg 发表于 2022-2-26 20:30:26

大马强 发表于 2022-2-23 16:19
字符串要用双引号

谢谢你

FlyingEgg 发表于 2022-2-26 20:41:12

isdkz 发表于 2022-2-23 19:36
除了 python ,其它的编程语言字符串都需要用双引号

谢谢!
页: [1]
查看完整版本: 关于cout的小问题