Re: [ROOT] Redirecting standard error

From: Colin Bernet (bernet@hep.saclay.cea.fr)
Date: Fri Jul 26 2002 - 11:51:01 MEST


Hi Alberto, 

If I understand correctly what you want to do, 
you can simply use the ofstream class : 

root [3] ofstream out("out.dat")
root [4] out<<"Hello World"<<endl
(class ostream)142600348
root [5] out.close()

[pccodt16] ~/Src/CoralDST/MDST > cat out.dat
Hello World
[pccodt16] ~/Src/CoralDST/MDST >


If you prefer to use C style I/O

root [12] FILE *f = fopen("colin.dat","w")
root [13] fprintf(f,"Hello World")        
(const int)11
root [14] fclose(f)                       
(int)0
root [15] 

You can do that from a compiled ROOT program too.
cheers, 

Colin

On Fri, 26 Jul 2002, Alberto Garcia Raboso wrote:

> Hi ROOTers,
> 
> I'd like to write an ASCII file with some data from a ROOT program, and
> the simplest way I've found is to write the data to cerr adn then
> redirect it to a file. But, how can I do this redirection? I'm running
> ROOT 3.03/02 on lxplus at CERN.
> 
> Cheers,
> 
> Alberto
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:01 MET