473,765 Members | 1,955 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cerr and clog

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
1 4351
> 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.tx t - output from sort is sent to the file
c:\temp\list.tx t.
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
953
by: Fuzzyman | last post by:
Nappy clog month... no, not the usual USENET abuse - it's an anagram of comp.lang.python...... http://www.voidspace.org.uk/atlantibots/nanagram.html An anagram finder with Tkinter front end in less than 20k of python - yep another great way to avoid working... mix up the names of friends and colleagues, great fun.
6
5599
by: Mike - EMAIL IGNORED | last post by:
I have a VC++6.0 program than calls library functions that write to cerr. I would like to capture this output in the calling program. Would you please let me know how I could to this? If I should ask on another group, please let me know. Thanks in advance, Mike.
2
7758
by: Trevor | last post by:
Hello, Please bear with me, I am trying to learn C++. I am implementing some error/debug functions which format a message and output it to a C++ stream. I would like to design it using one low level function which accepts a "generic C++ stream" as an argument (cerr, cout, ofstream, etc). I have tried to make the parameter a const ostream&, but when I plug in cerr or cout I get a compiler error. What am I doing wrong? // The low...
2
6018
by: Agoston Bejo | last post by:
Hi, how can one redirect std::cerr into a file? Specifically, if I have an ofstream object, is there something I can do to make "cerr << ..." calls write into that particular ofstream object? Thx, Agoston
1
3114
by: Gurikar | last post by:
How to redirect information to file usinf cerr or clog. Regards
8
18654
by: Dylan | last post by:
What advantages does std::cerr offer over std::cout? (I'm trying to understand why it exists) thanks
8
3553
by: sandwich_eater | last post by:
I get compiler error "cerr undeclared first use this function." #define err_ret(e) cerr << e; return -1 .... err_ret("who ate my muffy?");
3
7696
by: Scott | last post by:
Hi All, I have a C++ program that uses a library. This library (which I also wrote in C++), writes a series of status messages to clog as it goes about its work. In my program which utilizes this library, I am attempting to redirect clog to a stringstream, to allow me to output the status info as I decide it is necessary. So, I have this in my program: // redirect clog stringbuf *buf;
5
1497
by: mich dobelman | last post by:
I am developing a web crawler which collects info from more than 50,0000 pages. but i am afraid this is going to clog the rental web server if I run it every single day. Is it possible to stop the web hosting server because of my program? MD
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9951
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9832
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8831
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5275
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5421
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2805
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.