Category : C Source Code
Archive   : QCTBOX.ZIP
Filename : BITSTEST.C
Name: BITSTEST.C
Type: Demo Program
Lang.: Mic. Quick C
Video: No special requirements
Program list: Bitstest.c
Bits.c
Variables List: bit bitnumber
i Looping Index
j Looping Index
bitbuf Buffer of 1000 bits
Usage: (no command line parameters)
Description: Demos the Bits toolbox function.
-----------------------------------------------------------------
*/
#include
#include "bits.h"
main()
{
int bit;
int i, j;
unsigned char bitbuf[125];
/* Zero all the bits in the bit buffer */
for(bit=0; bit<1000;bit++)
bitclr(bitbuf, bit);
/* Set bits in first bite to set 'A' */
bitset(bitbuf, 0);
bitset(bitbuf, 6);
/* Toggle in second byte to set 'B' */
bittog(bitbuf, 9);
bittog(bitbuf, 14);
/* Print "AB" (third byte is /0 terminating the string) */
printf("First two bytes of bitbuf = %s\n",bitbuf);
/*Now set all bits */
for(bit=0; bit<1000;bit++)
bitset(bitbuf, bit);
/* Print decimal value of one of the bytes */
printf("bitbuf[97]=%d\n", bitbuf[97]);
/* Seive of Erastosthenes creates table of primes */
for( i=2; i<500; i++)
if( bitget(bitbuf,i) )
for( j=i+i; j<1000; j+=i)
bitclr(bitbuf, j);
/* Output all primes less than 1000 */
printf("Primes less than 1000\n");
for(i=1; i<1000; i++)
if(bitget(bitbuf, i))
printf("%d\t",i);
}
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/