I am writing binary file with the following code in FORTRAN:
Character(50) S
Real*8 A
A = 25.002
OPEN(1,file='data.bin', access='stream',action='write')
WRITE (1) A
CLOSE(1)
And trying to read that with the following code in C++:
ifstream::pos_type size;
char * memblock
ifstream file ("data.bin", ios::in|ios::binary|ios::ate);
if (file.is_open())
{
size = file.tellg();
memblock = new char [size];
file.seekg (0, ios::beg);
file.read (memblock, size);
file.close();
delete[] memblock;
}
But it does not work! The second code can not read the file created by the first code. Any help appreciated!