Variables in memory cross-platform...

SephirothSephiroth Fayetteville, NC, USA
Alright, this is a bit of a bugger, but it has to be done this way to avoid bloated code. I am reading a file into memory that was written in 16bit DOS. Due to this, variable sizes do not match. This means that a 64bit long is much larger than the 16bit long stored in the data in memory. How can I take the four-byte long in memory and read it into an eight-byte long on my 64bit system? I need a method that is fairly quick since I'll be reading various data into various variables semi-frequently and I can't have pausing while it reads the old data into a new variable.

-[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

Comments

  • How about something like the following? (Assuming you have the types in32_t and int64_t that can hold your data.)

    [code]int32_t i;
    istream::read( (char*)&i, 4 );
    int64_t j = i;[/code]

  • Read it as "short"? short is 16 bits on every platform.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion