home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fish 'n' More 1
/
FishNMoreVol1.bin
/
more
/
code_examples
/
librar
/
packarra.c
< prev
next >
Wrap
Text File
|
1989-02-08
|
1KB
|
36 lines
/*--------------------------------------*/
/* */
/* PACKARRAY(X,X,X,X) */
/* */
/* Strips the most significant bit off */
/* of the bytes in a character array. */
/* The first argument is the character */
/* array. The second is the size of the*/
/* array. The third is the target char-*/
/* acter array. The fourth is the size */
/* of this array. */
/* */
/*--------------------------------------*/
void packarray(a,bb,c,d)
char a[];
int bb,d;
unsigned char c[];
{
int b,j,k,bctr,ctr;
b=ctr=bctr=0;
for (j=0;j<d;j++)
c[j]=32;
for (j=0;j<bb;j++){
for (k=6;k>=0;k--){
if (testbit(a[j],k)==1)
b+=power(2,7-bctr);
bctr++;
if (bctr==8){
c[ctr++]=b;
b=bctr=0;
}
}
}
if (bctr>0)
c[ctr]=b;
}