www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/13/20:14:36

Message-Id: <199908132341.TAA08734@delorie.com>
From: "Dan Gold" <TedMat AT CoastNet DOT com>
To: <djgpp AT delorie DOT com>
Subject: Re: From Bytes to Int and Char
Date: Sat, 13 Aug 1994 02:10:29 -0700
X-MSMail-Priority: Normal
X-Priority: 3
X-Mailer: Microsoft Internet Mail 4.70.1155
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com


----------
> 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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019