From: Henri Ossi Newsgroups: comp.os.msdos.djgpp Subject: Fopen, fgetc, pac_getc etc. problem Date: Wed, 28 Jan 1998 16:40:05 +0200 Organization: Telecom Finland News Service Lines: 42 Message-ID: <34CF4345.267BF63D@mail.htk.fi> References: <34CC6531 DOT A6869055 AT mail DOT htk DOT fi> Reply-To: henri DOT ossi AT mail DOT htk DOT fi NNTP-Posting-Host: pc1025.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 So, could someone tell me, how? Henri Ossi wrote: > 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 a byte from a file > 2)write byte to a file > > Char is a word(16bit), right? > So, fgetch reads a word. But I have to be able to read & write > a byte. > > 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