Howdy, Stranger!

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


Variables in memory cross-platform...

SephirothSephiroth Fayetteville, NC, USAMember Posts: 1,035
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.



  • janssonjansson Member Posts: 1
    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]

  • LundinLundin Member Posts: 3,711
    Read it as "short"? short is 16 bits on every platform.
Sign In or Register to comment.