From: Henri Ossi Newsgroups: comp.os.msdos.djgpp Subject: File reading Date: Mon, 26 Jan 1998 12:28:01 +0200 Organization: Telecom Finland News Service Lines: 35 Message-ID: <34CC6531.A6869055@mail.htk.fi> Reply-To: henri DOT ossi AT mail DOT htk DOT fi NNTP-Posting-Host: pc2006.public.htk.fi Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Hi. I've made a fractal program, and It can produce 24bit images on the screen (cool :) Now I'm planning to make it save the image to a .TGA file. I downloaded the TGA file specification, but I have one problem. How can I 1)read 8bits from a file 2)write 8bits to a file Char is 16bit long, right? So, fgetch reads 16bits (word), but I have to be able to read & write 8bits. How is this done? I looked from the source code of allegro, and there the TGA file reader was using "pack_getc()" -function to get bytes from the packet file, but I coudln't find the code of the function. I've been thinking about this kind of solution, could it work? c = "read the word from the file"; byte1 = c >> 8; byte2 = (c <<8)>>8; But I still can't write bytes with that one... Thanks for your answers. -Henri Ossi