C++ Logo


Advanced search

Re: [std-proposals] A standard way to redirect all standard output

From: Thiago Macieira <thiago_at_[hidden]>
Date: Mon, 13 Mar 2023 11:36:48 -0700
On Monday, 13 March 2023 08:55:44 PDT Frederick Virchanza Gotham via Std-
Proposals wrote:
> I was thinking it would be nice if the Standard Library allowed us to
> redirect all standard output (destined for stdout + stderr), if we
> were to define these two functions:

Why can't you use freopen()?

If your <iostream> streams are synced to the <stdio.h> ones, you've
accomplished what you wanted. If they are not, then turn it on.

write() is not part of the C or C++ standards. If you're at the POSIX level,
then just use dup2().

Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering

Received on 2023-03-13 18:36:50