Aright, now all of you might be tired of my sometimes info-lacking posts about binary files.
... but I have another quick question:
How do I write and read a double in a binary file?
Code as simple as the following does not work (which is the usual code for writing/reading an integer, string, etc. to a binary file)
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char *argv[])
{
double pi = 3.14;
double read;
ofstream binf1("bin.txt");
binf1.close();
fstream binf("bin.txt", ios::binary|ios::in|ios::out);
binf.write(reinterpret_cast<char*>(&binf), sizeof(double));
binf.read(reinterpret_cast<char*>(&read), sizeof(double));
cout<< "\n" << read << "\n";
system("PAUSE");
return EXIT_SUCCESS;
}
Thanks ;)