Mail Archives: djgpp/1999/08/13/20:14:36
----------
> From: Campbell, Rolf [SKY:1U32:EXCH] <cp1v45 AT americasm01 DOT nt DOT com>
> To: djgpp AT delorie DOT com
> Subject: Re: From Bytes to Int and Char
> Date: Friday, August 13, 1999 11:41 AM
>
> Nick wrote:
>
> > I am trying to load some data from a files, the 6 and 7th bytes are an
> > Integer and so are the 11th and 12th. How do I make them into an INT?
This
> > is what I used earlier
> >
> > char ver, type;
> > int sz, tz;
> >
> > sz = file_buffer[6] + file_buffer[7];
> > is that right?
>
> No. Here's the right way to do it. This code is not edian safe.
>
> sz = *(short*)(file_buffer+6);
// Shouldn't it be *(int)(file_buffer+6)
Dan Gold..
- Raw text -