I have an input file in which the first column is made by string and the rest are numeric values.
E2 1880 1 0 67.50 10.50 -1.00 -1.00
E2 1880 1 4 66.50 11.50 -1.00 -1.00
E2 1880 1 8 66.50 11.50 -1.00 -1.00
E2 1880 1 12 65.50 11.50 -1.00 -1.00
E2 1880 1 16 64.50 11.50 -1.00 -1.00
E2 1880 1 20 63.50 12.50 -1.00 -1.00
E2 1880 2 0 63.50 12.50 -1.00 -1.00
E2 1880 2 4 62.50 12.50 -1.00 -1.00
E2 1880 2 8 62.50 12.50 -1.00 -1.00
The problem is that I need to store the input file in a 2d array but when I try to do it I get only 0 and I suspect it is because in the first column there are not numeric values..
Here the code
sprintf(FILE,"test.dat");
IN.open(FILE,ios::in);
if(IN.is_open()){
while ( IN.good() ) {
getline (IN,line);
++data;
}
data -= 1;
}
IN.clear();
IN.close();
double** buf;
buf = new double* [data];
for(int k=0;k<data;k++) buf[k] = new double[COL];
for(int k=0;k<data;k++){
for(int j=0;j<COL;j++) buf[k][j] = 0.;
}
sprintf(FILE,"test.dat");
IN.open(FILE,ios::in);
if(IN.is_open()){
for(int j=0;j<data;j++){
for(int k=0;k<COL;k++){
IN >> buf[j][k];
}
}
IN.clear();
IN.close();
Many thanks!
E2 & 1880and including rest of elements ?buf[j][k];where is this initialized what properties(string,int, object ect.) does it have?bufdeclared as adoublearray?