Re: File IO

Tech-Archive recommends: Fix windows errors by optimizing your registry



Why not just use CFile. CFile is just a front end for CreateFile, ReadFile,
and WriteFile from the Win32SDK and they will work fine for what you're
doing regardless of whether or not you use Unicode. I'm not sure what
CreateFile, ReadFile, and WriteFile use under the covers, but I guess I
don't have to know.

Tom

"Ed" <eddie@xxxxxxxxxx> wrote in message news:edZPg.2392$x11.183@xxxxxxxxxxx
I normally have been opening files and reading them using the following
code:

//-----------------------------------------------------------
int i;
unsigned char bytes[3000], tdat[50];
FILE *in;

CString fname="test.dat";
in = fopen(fname, "rb");
fread(bytes, 2500, 1, in); // read the full file
fclose(in);

for(i=0; i<30; i++){
tdat[i] = bytes[i+70]; // extract some data from within bytes
}
//-----------------------------------------------------------

I have heard that the use of fopen & fread are frowned upon, not sure why.

How do I use "correct" code to open a file that contains 8,000,000 bytes
of binary data
and be able to extract any parts of the original file as needed??
I have been trying to apply some examples given in this newsgroup without
much luck.
Thanks for helping.




.



Relevant Pages