#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
cout<<"flush"<<flush;//flushes the buffer,adds no data
cout<<"ends"<<ends;//inserts a null,then flushes the buffer
cout<<"endl"<<endl;//inserts a newline,then flushes the buffer
cout<<"仔细观察现在光标的位置在哪里?";
system("pause");
return 0;
}
看一看就知道其中的区别了。
本文通过一个简单的C++程序示例介绍了cout中的不同输出控制符的作用:flush用于刷新缓冲区但不添加任何数据;ends插入空字符并刷新缓冲区;而endl则插入换行符并刷新缓冲区。通过运行程序可以直观地看到这些控制符的效果。
971

被折叠的 条评论
为什么被折叠?



