| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1735 人关注过本帖
标题:关于cerr,exit
只看楼主 加入收藏
karlzhouzhi
Rank: 1
等 级:新手上路
帖 子:70
专家分:0
注 册:2005-12-25
收藏
 问题点数:0 回复次数:6 
关于cerr,exit
cerr和cout有什么区别?
exit是什么意思,用得多吗,在什么场合用,怎么用?
比如:
搜索更多相关主题的帖子: exit cerr cout 
2006-02-09 17:11
karlzhouzhi
Rank: 1
等 级:新手上路
帖 子:70
专家分:0
注 册:2005-12-25
收藏
得分:0 
接上面比如:
if(s<0)
{
cerr<<"bad size"<<endl;
exit(1) //这是什么意思
}
2006-02-09 17:13
p1s
Rank: 4
等 级:贵宾
威 望:10
帖 子:454
专家分:3
注 册:2005-11-4
收藏
得分:0 
cerr和cout效果没有什么区别,cerr表示出错信息
exit(1)是强制退出程序,需要#include <stdlib.h>
2006-02-09 18:31
karlzhouzhi
Rank: 1
等 级:新手上路
帖 子:70
专家分:0
注 册:2005-12-25
收藏
得分:0 
谢谢:)
2006-02-09 18:48
null
Rank: 1
等 级:新手上路
帖 子:52
专家分:0
注 册:2006-2-3
收藏
得分:0 
cout:
The cout object corresponds to the standard output stream. By default, this stream is associated with the standard output device, typically a monitor. The wcout object is similar but works with the wchar_t type.

cerr:
The cerr object corresponds to the standard error stream, which you can use for displaying error messages. By default, this stream is associated with the standard output device, typically a monitor, and the stream is unbuffered. This means that information is sent directly to the screen, without waiting for a buffer to fill or for a newline character. The wcerr object is similar but works with the wchar_t type.

1. 坚决抵制日货 2. 批判共产主义,批判所谓的社会主义
2006-02-10 10:44
xyj
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2005-3-14
收藏
得分:0 
cout and cerr差不多,都是终端屏幕输出
exit(0)是正常退出
exit(1)是异常退出

岂能尽如人意,但求无愧于心!
2006-02-18 20:31
smallcat
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2006-2-20
收藏
得分:0 
cerr是标准错误设备,当程序测试并处理关键错误时,不希望程序的错误信息从屏幕显示重定向到其他地方,这是使用cerr流显示信息。写到cerr流中的信息不能被重定向,而cout则可以被重定向到其他地方(文件,内存等)。
exit函数一般用于出错情况下的退出程序。




逃避不一定躲的过,面对不一定最难过。孤单不一定不快乐,正如得到不一定能长久~~!◎#¥%
2006-02-21 18:06
快速回复:关于cerr,exit
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.023598 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved