By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,227 Members | 1,195 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,227 IT Pros & Developers. It's quick & easy.

cerr and clog

P: n/a
Hello,

I am not entirely clear on the difference between cerr and clog. When it
is more appropriate to use one versus the other? I am coding a simple C++
application that will issue error and warning statements based on an
input, and I would like to know whether these should both go to cerr, or
whether clog for warnings is a more appropriate choice (or I suppose, just
cout)?

Thank-you,
Scott
Jun 16 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
> I am not entirely clear on the difference between cerr and clog.

They only are tow different streams..
When it is more appropriate to use one versus the other? I am coding a simple C++ application that will issue error and warning statements based on an
input, and I would like to know whether these should both go to cerr, or
whether clog for warnings is a more appropriate choice (or I suppose, just
cout)?


Yes..
Some time ago, i red an article describing the way to get the streams into
different files using windows.

I've found this:

----------------------------------------------------------------------------------------------
Redirection, Pipes and Filters

Redirection
Directing output ( > ) from a program to a specific file or device
(different from the 'standard output' device: the screen).
Directing input ( < ) to a program from a specific file or device (different
from the 'standard input' device: the keyboard).
Pipe
A data-channel ( | ) in RAM that takes output from a program and feeds the
data as input to another program.
Filter
A program that accepts input data - does something to the data - and
delivers output data.
Both input and output may be redirected or piped.
DOS filters: find, more, sort

Examples:

dir > list.txt redirect output from dir to the file list.txt
- if the file does not exist, it is created
- if the file exists, it is overwritten.
dir >> list.txt redirect and append output from dir to the file list.txt
- if the file does not exist, it is created
- if the file exists, output is appended to end of file.
sort < names.txt > list.txt use the file names.txt as input to sort
- output from sort is sent to the file list.txt.
dir | sort pipe output from dir to sort
- output from sort is sent to standard output: the screen.
dir | sort > c:\temp\list.txt - output from sort is sent to the file
c:\temp\list.txt.
dir | sort | more - output from sort is piped to more
- more (a filter) delivers output one screenfull at a time.

Redirection and pipes may be used in batch files.
-----------------------------------------------------------------------------------

but i can't remember how to split the streams... sorry

bye bye

Gnafu

Jun 18 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.