【发布时间】:2013-03-03 17:40:54
【问题描述】:
我注意到在以下代码中:
cout << "Please enter your number: ";
cin >> Number;
cout << "Is this spaced";
C++ 命令窗口中的输出会自动将“Is this spaced”放在下一行。它将cin 行之后的任何内容都隔开,而无需使用流操纵器(为什么这称为流操纵器?)endl。而如果我只有代码:
cout << "Please enter your number: ";
cout << "Is this spaced";
它不会自动用“Is this spaced”分隔行。相反,两条线都连接在一起。我很想知道为什么会这样,因为我一直认为您需要endl 才能创建新的空间行。
谢谢!
【问题讨论】:
-
因为你按下了回车...你添加了换行符。
标签: c++ line cout spacing endl