delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/03/29/00:58:46

Message-ID: <38E13966.D7F7F643@videotron.ca>
From: Trancelucid <trancelucid AT videotron DOT ca>
X-Mailer: Mozilla 4.7 [en] (Win98; U)
X-Accept-Language: en
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>
Lines: 47
Date: Tue, 28 Mar 2000 17:59:50 -0500
NNTP-Posting-Host: 24.201.20.12
X-Complaints-To: abuse AT videotron DOT net
X-Trace: wagner.videotron.net 954283912 24.201.20.12 (Tue, 28 Mar 2000 17:51:52 EST)
NNTP-Posting-Date: Tue, 28 Mar 2000 17:51:52 EST
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I don't think it's possible to retrieve only one bit from a file.. it
must be at least the smallest memory type size, which is a byte. If you
know how many bits you want to read in advance (let's use 22 as an
exemple), then you could load a factor of this (eg: 22bits * 4 = 88bits
== 11 bytes) into a buffer, and work with this buffer. If you don't know
in advance, then your algorithm might become complex (or slow, or
both...) What is it for anyway? Maybe knowing the use for such an
algorithm would help finding a better way to do it.

I doubt the snippets retrieve only one bit at a time, but if they do,
please post its location..

	.(Trancelucid).
	  .  Jaune  .

Krogg wrote:
> 
> This method isnt what i am looking for....I know how
> to see the individual bits in a byte but i want to be
> able to say read the next n bits and see if they are
> on or off....maybe i want the next 7 or the next 22
> bits....I found some code in the snippits archive
> that seems promising for this purpose but i am still
> trying to figure out how to implement it....
> 
> Its got functions like these:
> 
> bfile * bfopen(char *name, char *mode);
> int     bfread(bfile *bf);
> void    bfwrite(int bit, bfile *bf);
> void    bfclose(bfile *bf);
> 
> and a struct like this:
> 
> typedef struct  {
>       FILE *  file;       /* for stream I/O   */
>       char    rbuf;       /* read bit buffer  */
>       char    rcnt;       /* read bit count   */
>       char    wbuf;       /* write bit buffer */
>       char    wcnt;       /* write bit count  */
> } bfile;
> 
> I am trying to figure out how to chop out the junk
> and use this,but if some one esle had some thing better
> i would welcome the help.
> 
> Thnaks.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019