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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi, I'm more ore less starting t 1

Status
Not open for further replies.

SPRobson

Programmer
Jul 5, 2001
18
EU
Hi,

I'm more ore less starting to use C++ with VC5.0. Can anyone tell me how to read in (and convert to integers) a specific number of bytes from a binary file using CFile?

Thanks alot

Simon
 
I would use CFile::Read

char buffer[NUM_BYTES];
CFile myFile;
myFile.Open("Filename",CFile::modeRead | CFile::shareDenyWrite);

myFile.Read(buffer,NUM_BYTES);

buffer now has the number of bytes you want.

Matt
 
Sorry... to convert the integers you can use the function

int x = atoi(buffer);

if buffer is not in base 10 I belive you will want to look into strtol(buffer,base);

matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top