注册 登录
编程论坛 C++教室

请问一下clog 的问题

死了都要C 发布于 2007-11-25 16:58, 1384 次点击
书上是这样的:

          clog对象用于产生程序执行的一般信息.

          一般情况下,系统将 cin, cout, cerr, clog对象与执行程序的窗口联系起来.这样,当我们从cin读入时.大部分数据从执

行程序的窗口读入,当写到cout, cerr 或 clog 时, 输出写至同一窗口,运行程序时. 大部分操作系统都提供了重定向输入或输

出的方法.利用重定向可以将这些流与所选择的文件联系起来.


          红字看不懂```clog是怎么用的啊```那个````重定向输入或输出```又是怎么回事呢```

请大家帮帮忙```谢谢````
7 回复
#2
aipb20072007-11-25 17:43
MSDN下吧

clog没用过!
#3
死了都要C2007-11-25 17:58
MSDN```应该很大吧```我是网吧学的```没有自己的电脑啊```
#4
aipb20072007-11-25 18:05
在线 MSDN 啦。

baidu,google
#5
死了都要C2007-11-26 12:41
恩````去看看````
#6
死了都要C2007-11-26 13:09
刚才搜了好多啊``都找不到啊````55555``能给个网址吗?~``
#7
aipb20072007-11-26 13:15
clogSee Also
<iostream> Members | ostream
Specifies the clog global stream.

extern ostream clog;
Return Value
An ostream object.

Remarks
The object controls buffered insertions to the standard error output as a byte stream.

Example
See cerr for an example of using clog.

————————————————————————————————————
cerrSee Also
<iostream> Members | ostream
Specifies the cerr global stream.

extern ostream cerr;
Return Value
An ostream object.

Remarks
The object controls unbuffered insertions to the standard error output as a byte stream. Once the object is constructed, the expression cerr.flags & unitbuf is nonzero.

Example
// iostream_cerr.cpp
// compile with: /EHsc
// By default, cerr and clog are the same as cout
#include <iostream>
#include <fstream>

using namespace std;

void TestWide( )
{
   int i = 0;
   wcout << L"Enter a number: ";
   wcin >> i;
   wcerr << L"test for wcerr" << endl;
   wclog << L"test for wclog" << endl;   
}

int main( )
{
   int i = 0;
   cout << "Enter a number: ";
   cin >> i;
   cerr << "test for cerr" << endl;
   clog << "test for clog" << endl;
   TestWide( );
}
Input
3
1
Sample Output
Enter a number: 3
test for cerr
test for clog
Enter a number: 1
test for wcerr
test for wclog
#8
aipb20072007-11-26 13:24
简单来说就是clog带缓冲区,cerr不带,均为标准错误流。

重定向就是指cout可以用于输出到显示器以外的设备关联,比如文件。

[[italic] 本帖最后由 aipb2007 于 2007-11-26 13:30 编辑 [/italic]]
1