delorie.com/archives/browse.cgi | search |
Message-ID: | <38B3D5D3.35890A0@ozemail.com.au> |
From: | Infinity da Gook <dagook AT ozemail DOT com DOT au> |
X-Mailer: | Mozilla 4.7 [en] (Win98; I) |
X-Accept-Language: | en |
MIME-Version: | 1.0 |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | something wierd with shorts and ints...help! |
Lines: | 51 |
Date: | Wed, 23 Feb 2000 23:43:00 +1100 |
NNTP-Posting-Host: | 210.84.135.60 |
X-Trace: | ozemail.com.au 951309754 210.84.135.60 (Wed, 23 Feb 2000 23:42:34 EST) |
NNTP-Posting-Date: | Wed, 23 Feb 2000 23:42:34 EST |
Organization: | OzEmail Pty Ltd, Australia |
Distribution: | world |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
this iz prolly just a really simple thing...but i got no idea what's causing it.... i have a struct.... //============ typedef struct { byte marker[8]; // where byte was prev defined az unsigned char short pad; int CatEntries; int BaseOffset; } TLKHeader_t; //============== now when i load the data from a binary file... 54 4C 4B 20 56 31 20 20 00 00 FA 50 00 00 76 39 08 00 the 'marker' array should contain this... 54 4C 4B 20 56 31 20 20 the 'pad' should contain.... 00 00 the 'CatEntries' should contain... FA 50 00 00 and 'BaseOffset' ... 76 39 08 00 but it doesn't!!! 'marker' and 'pad' come out fine....but 'CatEntries' comes out with... 00 00 76 39 'BaseOffset' iz similarly skrewed... with 08 03 xx xx but when i dump the struct to a file, it comez out a perfect copy of the original. (????) it seemz to me that while the struct iz read from the file properly, the pad (short) somehow occupies 4 bytes rather than 2 and offsets the rest of the struct...(??pure speculation??) in case u're wondering, i'm reading the file using fstream.... //================== fstream TLKIO; TLKIO.open ("dialog.tlk", ios::in | ios::binary | ios::nocreate); TLKIO.read ((char*)&header, sizeof(TLKHeader_t)); // where header iz an instance of TLKHeader_t //================== can somebody give me any help!??! --==Infinity==--
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |