Date: Mon, 3 Nov 1997 17:38:16 -0800 (PST) Message-Id: <199711040138.RAA10984@adit.ap.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" To: Oon Lin , djgpp AT delorie DOT com From: Nate Eldredge Subject: Re: getc() and getw() Precedence: bulk At 05:06 11/3/1997 +1000, Oon Lin wrote: >Hi.. > >I'm having problem trying to use getc() and getw() to work.. > >I have the code to read in the header of a PCX file and put them into a >structure > >But when I use getw() to read in the width and height field I get a zero >instead of the value that I'm expecting... I'm afraid I don't have the time to read all your code, but IIRC those fields of a PCX header are 16-bit values. getw() reads an `int', which is 32 bits for DJGPP. It's usually a bad idea to use such compiler-dependent functions. Try `fread' into a `short' with size==2 instead. > >And when I use getc() to actually get the all the RLE data (through >using a loop) I get either zero or inconsistent values everytime I run >the program... That I don't know about, unless it's caused by the getw()'s leaving you at the wrong place in the file. > >Hmm.. could this be caused GCC's buffered input / output ?? I had set >the buffer to NULL using setbuf() and even packed the structures (I >doubt it's this problem..) but I still can't get the data corerctly... The buffering won't affect it at all, and packing the struct will only make a difference if you fread() directly into it, which it seems you don't. >Everything is fine when I use Turbo C 2.0 but not GCC (DJGPP 2.0) That would support my theory of the getw() problem. Nate Eldredge eldredge AT ap DOT net