Re: reading a binary file
Stephen Markacs (stephen@cuphy3.phys.columbia.edu)
Thu, 15 Apr 1999 14:35:39 -0400 (EDT)
> {
> ifstream f;
> int bufferSize = 10;
> int* buffer = new int(bufferSize);
^ ^
These parenthesis should be brackets [].
As you have it, bufferSize is used to initialize the single integer that
buffer points to rather than specifying how big the buffer is.
>
> f.open("testdata/test.dat",ios::binary);
>
> f.read( (char*)buffer, bufferSize*sizeof(int));
>
> for (int i=0;i<bufferSize;i++)
> cout << *(buffer++) << endl;
> }
S t e p h e n M a r k a c s
stephen@phys.columbia.edu
http://phys.columbia.edu/~stephen/