home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 1 / FishNMoreVol1.bin / more / code_examples / librar / packarra.c < prev    next >
Text File  |  1989-02-08  |  1KB  |  36 lines

  1. /*--------------------------------------*/
  2. /*                    */
  3. /*           PACKARRAY(X,X,X,X)        */
  4. /*                    */
  5. /* Strips the most significant bit off  */
  6. /* of the bytes in a character array.    */
  7. /* The first argument is the character    */
  8. /* array.  The second is the size of the*/
  9. /* array.  The third is the target char-*/
  10. /* acter array.  The fourth is the size    */
  11. /* of this array.            */
  12. /*                    */
  13. /*--------------------------------------*/
  14. void packarray(a,bb,c,d)
  15. char a[];
  16. int bb,d;
  17. unsigned char c[];
  18. {
  19.     int b,j,k,bctr,ctr;
  20.     b=ctr=bctr=0;
  21.     for (j=0;j<d;j++)
  22.              c[j]=32;
  23.     for (j=0;j<bb;j++){
  24.              for (k=6;k>=0;k--){
  25.                   if (testbit(a[j],k)==1)
  26.                       b+=power(2,7-bctr);
  27.                   bctr++;
  28.                   if (bctr==8){
  29.                       c[ctr++]=b;
  30.                       b=bctr=0;
  31.                   }
  32.              }
  33.     }
  34.     if (bctr>0)
  35.             c[ctr]=b;
  36. }