RE: [ROOT] iostream

From: Philippe Canal (pcanal@fnal.gov)
Date: Mon Sep 29 2003 - 19:55:58 MEST


Hi,

The problem is that
	fout << i*0.1;
does not introduce any separation between the numbers.
Hence the data ile looks like:
  00.10.2
which is properly parse as
	00.10
	.2
	error (which result in 'arr' to be unmodified and stay 0.2)
To fix your problem use
	fout << i*0.1 << ' ';
Cheers,
Philippe

-----Original Message-----
From: owner-roottalk@pcroot.cern.ch [mailto:owner-roottalk@pcroot.cern.ch]On
Behalf Of Dong Zhou
Sent: Monday, September 29, 2003 7:04 AM
To: roottalk@pcroot.cern.ch
Subject: [ROOT] iostream


dear rooters:

i feel there is something wrong with the 'fin >>' method.

my code is like this:
// tmp.cpp
void tmp(){
ofstream fout ("tmp.dat");
Double_t arr;

for(int i=0;i<3;++i){
 fout << i*0.1;
}
fout.close();
ifstream fin("tmp.cpp");
for(i=0;i<3;++i){
 fin >> arr;
 cout << i << ' ' << arr << endl;
}
}

it should be 0 0.1 0.2
but the output turns out to be 0.1 0.2 0.2
it seems that it take 00.1 as 0.1

i am not sure if i have made any mistake. what is ur opinion?
thank u.

zhou, dong




Do You Yahoo!?
启用电邮帐号,领会雅虎通[身临其境聊电影]的动感魅力,还有网络摄像头+雅虎通收
音机等你来拿


#################################################################
#################################################################
#################################################################
#####
#####
#####
#################################################################
#################################################################
#################################################################



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:15 MET