Re: safe alternative to va_arg



Hi Uli,

BTW: a very convenient feature of C++ IOStreams is the overloaded rdbuf()
function. Using that, you can easily redirect a stream to stdout, a file or
any other stream:

int main() {
std::ofstream out("program.log");
std::cout.rdbuf(out.rdbuf());
:

Is it possible to redirect the output to multiple targets, e.g. to both a
file and the console?

Thanks,

Fabian
.



Relevant Pages

  • Re: How it works?
    ... The following code is working fine and printing the string "Mohan S". ... int main ... it's implementation-defined whether a stream (such ... as stdout) is required to end in a newline. ...
    (comp.lang.c)
  • Re: pipedstreams
    ... time readInt returns values that has never been written to the stream ... to put the wrapped streams into your Comm object. ... catch (IOException e){System.err.println("An error occured ... public synchronized void send(int dest, ...
    (comp.lang.java.programmer)
  • Re: Sending XML data via socket
    ... I looked int a link you have provided. ... // Get a stream object for reading and writing ... Resize the buffer, put in the byte we've just ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: adapting getline
    ... int getline; ... The function reads characters from the input stream stream and stores them ...
    (comp.lang.c)
  • Re: how to remove code duplication
    ... the log directory should containing the same files as the out ... exit(EXIT_FAILURE); ... int main ... void process_log_data(FILE *stream) ...
    (comp.lang.c)