cerr and clog

S

Scott

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
 
G

Gnafu

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,266
Latest member
DavidaAlla

Latest Threads

Top