Hello!
The program reads data from a file containing 7440 lines. Each line is written to the vector.
How can I transfer elements of this vector to a four-dimensional array?
void myClass::conversion() { int ix, iy,iz; double* myarray=&myvec[0]; typedef double MyType[26][2][40][5]; for(int i=0 ;i<26;++i) { for(int j=0; j<2; ++j) { for(int k=0;k<40; ++k) { if(!index(i, j ,k, iz, ix, iy))continue; //проверяем индексы for(int l=0; l<5; ++l) { cout<<reinterpret_cast<MyType &>(*myarray)[0][j][k][l]<<endl; } } } } } Printing produces completely different values, they are present in the file, but the indexing does not match, although a similar test for a two-dimensional array worked. In addition to reinterpret_cast , what other solutions are there for such problems?
myvec-vector<double>? and it is not known whether you are correctly recording the data read from the file - maybe you are confusing something there in the indexes ... - Harrydouble, the filling is performed correctly, because the value for the index n corresponds to the value from the file for the line n + 1 - DefileR