I wan to wirte in cout << ... to have the matrix in output in the same format that I wrote it in text file like this:
1 2 3 4 5
2 3 4 5 6
3 4 5 6 7
class Classname {
double data[3][3];
public:
void Read(char *fname);
void Writedata();
}
void Classname::Read(char *fname)
{ int i, j;
ifstream fin(fname);
fin >> 3;
// read the matrix
for(i= 0; i<3; i++)
for(j= 0; j<3; j++)
fin >> data[i][j];
}
void Classname::Writedata(char *fname)
{ // writes model to cout in same format it was read in
cout << "matrix = " << endl;
cout << matrix[0][0] << " " << matrix[0][1] << " " << matrix[0][2] << endl;
cout << matrix[1][0] << " " << matrix[1][1] << " " << matrix[1][2] << endl;
cout << matrix[2][0] << " " << matrix[2][1] << " " << matrix[2][2] << endl;
};
void pbsolve(char *fname)
{
cout << "pbsolve " << fname << endl;
Classname pb;
np.Read(fname);
np.Writedata(fname);
}