Dear Root Gurus,
I would like to know how one can read some floats and/or integers from
a TString already read from an ASCII file. I mean the equivalent of
the
FORTRAN:
integer count
real x, y
read(10,'(a)') line
* for instance do a test on the first character to see the line is
a comment
* line or to see if it contents useful variables and in that case:
read(line,*) x, y, n
Here is what I would like to perform in Root/C++ for instance:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <iostream.h>
#include <fstream.h>
#include "TString.h"
int main()
{
// ouverture fichier d entree:
ifstream fin;
fin.open("essai.dat");
if (!fin) {
cout << "Unable to open essai.dat for reading\n";
return(1);
}
// ouverture fichier de sortie:
ofstream fout;
fout.open("essai.out");
// create base string
String line;
Int_t count;
Float_t x, y;
ligne.ReadLine(fin);
cout << line << endl;
// tests if it is a comment line starting for instance by #,
Maybe this functionality already exists in the TString class, but I
do not know
how to use it.
Thank you for any help,
Gilles Quemener
-- _____________________________________________________________________ Gilles Quéméner tél: (33) (0)4-76-28-40-60 Institut des Sciences Nucléaires fax: (33) (0)4-76-28-40-04 53, Avenue des Martyrs http://www.cebaf.gov/~quemener 38026 GRENOBLE cedex FRANCE
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:43 MET