From: "Campbell, Rolf [SKY:1U32:EXCH]" Newsgroups: comp.os.msdos.djgpp Subject: Re: From Bytes to Int and Char Date: Fri, 13 Aug 1999 14:41:27 -0400 Organization: Nortel Networks Lines: 21 Message-ID: <37B466D7.958F09E5@americasm01.nt.com> References: NNTP-Posting-Host: bmerhc00.ca.nortel.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.7 [en] (X11; I; HP-UX B.10.20 9000/712) X-Accept-Language: en To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com 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); -- -Rolf Campbell (39)3-6318