RE: [ROOT] dynamic allocation and string

From: Tommaso Chiarusi (Tommaso.Chiarusi@bo.infn.it)
Date: Thu Mar 14 2002 - 20:41:22 MET


thanks Philippe.
To be more precise I've to attach my file.

I point out the points where I use the <string>:

starting from line 136

  //--------- Make the LIST of the data ascii file to process 
  system("rm -f lista.txt");
  system("'ls' link | awk -F '.' '{print $0, $1}' >> lista.txt");
  
  ifstream listafile("lista.txt");
  ifstream *ff[26];

  char nomeintero[20];
  char nomecorto[20];
  int luppa=0;
  string st[26];
^^^^^^^^^^^^^^^^^^^^^^^

  while(listafile>>nomeintero>>nomecorto)
    {
      ff[luppa] = new ifstream(nomeintero);
      st[luppa]=nomecorto;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      luppa++;
    }


and from line 248

// ---------- Various Tree Filling
for (int lu=0;lu<27;lu++)
  {
    char *nome=st[lu].c_str();
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    azione(ff[lu],cr,1,delta,nome);// call the function on top of this file
   }



Thanks a lot!
Tommaso


 
 Unfortunatly at the end of my macro I get the following error:
> > ----------
> > *** Break *** segmentation violation
> > Root > Function faitree_obj_dev() busy flag cleared
> > Function c_str() busy flag cleared
> > Function length() busy flag cleared
> 


Note that in the Book "C++ Primer"
suggest to set "const" the C-style string,
i.e.
       const char *nome=st[lu].c_str();

but ROOT fails (or something else goes wrong), giving this error:







This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:45 MET