Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MFC: scanning in a file to get the last value

Status
Not open for further replies.

mfm

Programmer
Jul 9, 2001
16
FR
Hi, I'm trying to find what function do i need to use in scanning in a hex file, to find the last value and return that value; and I think I need to use CFile class (or is it the CStdioFile class do i need to use instead?)
any idea? thx a lot
 
Either would be fine. CFile is the parent of CStdioFile.

Here is one approach with CFile (and because of inheritance will work with stdio as well)

CFile f;
f.Open("Filename",CFile::modeRead|CFile::shareDenyNone);

// if you know how many bites the last value is set numBytes to the negative of that, if not, the max size a value can be is 64 bits (unlikely) or 32 (most probable)
f.SeekToEnd();
int numbBytes = sizeof(int)*(-1)
f.Seek(numBytes);

int val;
f.Read(&val,sizeof(int));

Good luck.

Matt
 
thx Matt,
i manage to find out another way to overcome my problem, which is rather straight forward. I didn't realise just now. Btw, thx a lot for your support.
Cheers!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top