Re: [ROOT] CINT, TString streamer, What I did wrong

From: Rudi Lutter (Rudi.Lutter@Physik.uni-muenchen.de)
Date: Mon Jul 03 2000 - 08:21:10 MEST


On Fri, 30 Jun 2000, Hugues Delagrange wrote:
>
>Hi,
>    I run on a linux Box  RH 6.2 with
>                          ROOT Version   2.25/00      19 June 2000 ,
>                         Compiled with thread support.
>                         CINT/ROOT C/C++ Interpreter version 5.14.40,
>May 21 2000
>
>
>   and I got something weird trying to read a string in a file. The
>macro is the following :
>{
>   gROOT->Reset();
>   ifstream fin;
>   fin.open("FileForPb.DAT", ios::in);
>   TString wrkString;
>   fin >> wrkString ;
>   cout << " WrkString ?? : " << wrkString << endl;
>}
>
>and I got back :
>Enclose multiple statements between { }.
>root [0] .x PbTString.C
> WrkString ?? :
> *** Break *** segmentation violation
>Root >
> *** Break *** segmentation violation
>
>....... almost an endless  litany of these!!
>

>Does someone have any clue ? I must also emphasize it did work with the
>preceding version of ROOT, indeed. It was V2.23-12.Linux-2.2.14.

>Thanks in advance.
>
>Hugues Delagrange
>
>

Hi Hugues,

you should use method TString::ReadLine() or TString::ReadString() instead:

             wrkString.ReadLine(fin);

ReadLine looks for EOL, ReadString stops at a 0-char.

Rudi
-- 
         __     __  __              |  Rudi Lutter
  ____  / /_ __/ /_/ /____ ____     |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 / __/ / / // / __/ __/ -_) __/     |  Email: Rudi.Lutter@Physik.Uni-Muenchen.DE
/_/   /_/\_,_/\__/\__/\__/_/        |  Tel:   (089) 289 1 4287
                                    |  Fax:   (089) 289 1 4280
--------------------------------------------------------------------------------



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:29 MET