Copying to binary file row of a matrix
- by Flethuseo
Hi everyone
I want to write each row of a matrix to a binary file.
I try writing it like this:
vector< vector<uint32_t> > matrix;
...
for(size_t i = 0; i < matrix.size(); ++i)
ofile->write( reinterpret_cast<char*>(&matrix[i]), sizeof(uint32_t*sizeof(matrix[i])) );
{
for(size_t j = 0; j < numcols; ++j)
{
std::cout << left << setw(10) << matrix[i][j];
}
cout << endl;
}
but it doesn't work, I get garbage numbers.
Any help appreciated,
Ted.