Code:
#include <iostream>
#include <fstream>
using namespace std;
int main() {
fstream in ("data.in", ios_base::in);
fstream out ("out.data", ios_base::out|ios_base::in);
in.seekg (0, ios::end);
int size;
size = in.tellg();
char * memblock = new char [size+1];
in.seekg (0, ios::beg);
in.read (memblock, size);
memblock[size] = 0;
cout << " mem bloxk " << memblock;
out << memblock;
delete [] memblock;
}
This works fine for me. But I'm on a linux box and there is no difference between text and binary files.
I wonder why you open out for in and output. Ths will prevent out to be created if it doesn't exist.
I would try opening the streams in binary mode
like this
Code:
fstream in ("data.in", ios_base::in | ios::binary);
Kurt