Hi Arthur,
I can not reproduce the problem (or do not understand your description :) ).
Can you send me a complete running example (and the output as you see it) as well as the version of ROOT where it fails for you).
Cheers,
Philippe.
-----Original Message-----
From: owner-roottalk_at_pcroot.cern.ch [mailto:owner-roottalk_at_pcroot.cern.ch]
On Behalf Of Arthur E. Snyder
Sent: Monday, April 02, 2007 4:43 PM
To: Rene Brun
Cc: 'roottalk (Mailing list discussing all aspects of the ROOT system)'
Subject: [ROOT] TString bug (or feature)?
Hi Rene et al.,
I find that when I try to read the blank separated charachters in a line into TString from an istringstream it has a strange behavior. If the last character is followed directly by a line-feed it gets skipped. Apparently eof or something is set by reading it and the loop ends w.o. giving you a chance at the characters just read. The result is you lose the last character string. If I use std::string instead, it works as I expect it too.
The code is as follows:
#include "readCard.hh"
#include <TString.h>
#include <iostream>
#include <vector>
#include <string>
using std::istream; using std::endl; using std::cout;
//read strings till "eol" marker or natural end; if nread!=0 read nread
string (no marker)
Int_t readCard(istream& card,std::vector<TString>& list,Int_t nread) {
Int_t count=0;
TString temp;
// std::string temp;
while(card >> temp) {
cout << "count:" << count << " temp:" << temp << endl;
if(nread==0 && temp=="eol") break; if(nread==0 && temp=="*eol") break; if(nread==0 && temp=="!eol") break;
list.push_back(temp);
if(count==nread) break;
} // loop
return count;
}
-Art S. Received on Wed Apr 04 2007 - 09:56:40 CEST
This archive was generated by hypermail 2.2.0 : Wed Apr 04 2007 - 23:50:01 CEST