小编con*_*ong的帖子

什么是C++中的cin运算符顺序

我在C++中有关于cin和cout顺序的问题,例如:

int a,b;
std::string c;
std::cin >> a >> b >> c >> c >> a;
std::cout << a << " " << b << " " << c << " " << a;
Run Code Online (Sandbox Code Playgroud)

如果输入是"5 10 hello world 15 20",输出是什么,我可以看到结果,但任何人都能解释一下它是如何工作的吗?cin赋值5变量,但输入是6个值,cin和cout的顺序是什么?

c++

2
推荐指数
1
解决办法
4229
查看次数

为什么这段代码输出文字"\n"而不是换行?

以下代码的输出是什么?

std::cout<<"what is the output \\n hello \'world\' world";
Run Code Online (Sandbox Code Playgroud)

我认为输出应该是:

what is the output
hello 'world' world
Run Code Online (Sandbox Code Playgroud)

但实际产量是 the output \n hello 'world' world

为什么\n输出不是新线?

c++

0
推荐指数
1
解决办法
2737
查看次数

标签 统计

c++ ×2