On Apr 19, 2:13 am, Mark P <use..@fall2005REMOVE.fastmailCAPS.fm>
wrote:
Bryan wrote: In unix if I want to dump some output into never never land I can do
something like:
std::ofstream outfile('/dev/null');
What is the equivalent in windows? /dev/null seems not to work properly.
Is it std::ofstream outfile('NUL')?
Not certain of this, but I would expect that you can simply default
construct an ofstream without specifying a file name.
Yes, but that will result in an error; typically, an output
error will cause the code to fail. (Output errors are normally
fairly serious, except for secondary output, like logging.)
It's pretty simple to define a nulstreambuf, which emulates the
behavior of '/dev/null' exactly. (EOF for all reads, success
for all writes.) Then just create an ostream with this as the
streambuf.
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34