RE:(Fwd) Problem with CINT using istream

From: Masaharu Goto (MXJ02154@nifty.ne.jp)
Date: Thu Sep 17 1998 - 15:22:00 MEST


Irwin, Fons and Valery,

I think following code is not accepted by C++.

   #include <iostream.h>
   float a[38,10]; // This is equivalent to a[38] or a[10]. 
   ifstream inp("btev2_trim",ios::in);
   inp >> a; // this can't call operator(ifstream& ifs,float*& x);

C++ can not distinguish functions parameter that differ only by referencing
and pointer/array. In other words, you can not overload following functions.

     ifstream& operator(ifstream& ifs,float*& x);
     ifstream& operator(ifstream& ifs,float[] x);
     ifstream& operator(ifstream& ifs,float* x);
     ifstream& operator(ifstream& ifs,const float* x);

This means , C++ can not tell a difference between

   float **ppf;
   inp >> ppf;

and

   float a[10];
   inp >> a;

You can not even compile 'inp >> a'.

Suggestion,
 I'm not sure the intention of a[39,10]. I assume you wanted 2-dim array. Then
 'float a[38][10];' is the correct declaration.

 2nd, C++ nor CINT can implicitly loop reading array. You need to explicitly
 write loops, I think.

C++ is so complex. I might make mistake. Please inform me if I'm wrong.

Masaharu Goto

---------------------------------------------------------------
 Hello Masa , 
 I tried the example below under the "pure" CINT (under NT and under 
Sun OS as well). Neither works.

    Could you comment.
                             Valery

------- Forwarded Message Follows -------
Date:          Wed, 16 Sep 1998 16:58:44 -0500
From:          Irwin Gaines <gaines@fnal.gov>
Subject:       Problem with CINT using istreams
To:            rootdev@hpsalo.cern.ch

I am running ROOT(V2.00/11) on a windows 95 system, and am trying to
read in a simple ascii text file.  I executed the following statements
in CINT:

#include <iostream.h>
float a[38,10];
ifstream inp("btev2_trim",ios::in);
inp >> a;

and i get the following error:

ROOT caused an invalid page fault in
module <unknown> at 0084:00e2e7f1.
Registers:
EAX=00e2e3a0 CS=0137 EIP=00e2e7f1 EFLGS=00010a03
EBX=01072424 SS=013f ESP=01535cec EBP=00000004
ECX=ffffffff DS=013f ESI=00e2e3a0 FS=3907
EDX=0153ac2c ES=013f EDI=00e2e780 GS=0000
Bytes at CS:EIP:
3a 5c 77 69 6e 64 6f 77 73 5c 54 45 4d 50 5c 34
Stack dump:
0049720c 00e2e3a0 0153ac44 010728e0 00450959 0153ac2c 00000000
0153ae20 00000000 0153ae20 0153ac2c 00e2e3a0 01072424 0044367d
0153ac2c 0153ae20

Do you have any idea what is wrong??  (by the way, if i try to just
read in a 1-d array by doing float a[38]; the program just hangs up
without any error message but never returns to the ROOT prompt). 
thank you,

Irwin Gaines



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:37 MET