[ROOT] Basic file stream operation in ROOT

From: Exaos Lee (schlie@iris.ciae.ac.cn)
Date: Thu Jun 26 2003 - 07:59:44 MEST


Dear rooter,
I want to read a string from an ASCII file. I use the following code:
---
ifstream idx_in("evnt_index.txt",ios::in);
std::string evnt_fn;
....
idx_in >> evnt_fn;
---
When root reaches "idx_in>>evnt_fn", it warns:
----
Error: operator>> not defined for basic_ifstream<char,char_traits<char>
> FILE:e2r_1.C LINE:60
*** Interpreter error recovered ***
----
How to solve this problem?

How to make sure a file is open in root? I use this code:
----
ifstream evnt_in;
...
evnt_in.open(evnt_fn, ios::in | ios::binary);
assert(evnt_in.is_open());
----
Does the statement "assert()" work with CINT?


Best regards.

Exaos



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