Message-ID: <38E15B56.C4666CA6@gtcom.net> From: Krogg X-Mailer: Mozilla 4.61 [en] (Win95; U) X-Accept-Language: en-US,en-GB,en,ja MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Re: help with a bit stream.... References: <38E0FCF9 DOT AB82C211 AT gtcom DOT net> <38E1019E DOT B5E2F47C AT corel DOT com> <38E105BC DOT E528B7F0 AT corel DOT com> <38E12ED5 DOT 7205297F AT gtcom DOT net> <83em8uej0u DOT fsf AT mercury DOT st DOT hmc DOT edu> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 65 Date: Tue, 28 Mar 2000 20:24:38 -0500 NNTP-Posting-Host: 12.6.67.14 X-Trace: eagle.america.net 954293192 12.6.67.14 (Tue, 28 Mar 2000 20:26:32 EST) NNTP-Posting-Date: Tue, 28 Mar 2000 20:26:32 EST Organization: 24hoursupport.com To: djgpp AT Delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Nate Eldredge wrote: > > I suspect what you'd do is to have a buffer of at least one byte, then > return bits from this buffer, and refill it when empty. Something > like: > > int buf; /* we really only use one byte of it */ > int bits_left = 0; > > /* Note this reads the least significant bit first... it could be > changed. */ > int get_bit() { > int bit; > if (bits_left == 0) { > buf = getc(input); /* read one byte */ > /* handle error or EOF case */ > } > bit = buf & 1; /* get least significant bit */ > buf >>= 1; /* shift for the next time */ > bits_left--; /* and note that we've used one bit */ > return bit; > } > > Presumably the code you have does the same thing, but associates a > buffer with each file (which is why there are the funny structs). > This allows you to get bits from multiple files at once. Yes,this is the actual code...(its found in "bitfiles.c" from the snippits code collection that can be downloaded from: http://www.snippets.org/ ) int bfread(bfile *bf) { if (0 == bf->rcnt) /* read new byte */ { bf->rbuf = (char)fgetc(bf->file); bf->rcnt = 8; } bf->rcnt--; return (bf->rbuf & (1 << bf->rcnt)) != 0; } I just dont understand how the end of file was implemented yet..... The header file #includes other headers and those #include other headers...I just want to chop everything up and put it in one file that i can #include in my sources..... I am finding this difficult,cause i dont understand all the caveats of headers and #include'd files....Anyhelp on doing this would be SUPER cool. -- |"""""<`.THE PRINCE ,'>"""""""""""""""""""""""""""""""""""| | `.`/""""""\,',' my sig is too big, | |SEE HIS ( / \ \' SEE HIS but its really cool. | | FACE \/<> <>\/ SMILE | | / W \ Visit my ascii art site: | | ,'\_|||||_/`. http://www.gtcom.net/~krogg/ascii/ | | ,',' ||| `.`. krogg DOT no DOT to DOT spam AT gtcom DOT net | |____<,' TIME TO DIE `.>____Remove no.to.spam to reply____|