lsflib/src/bindump.c
changeset 6 c3dc3eb3b541
child 9 c3fecc82ade6
equal deleted inserted replaced
5:d752cbe8208e 6:c3dc3eb3b541
       
     1 /*
       
     2  *  $Id: bindump.c 94 2008-04-05 01:27:30Z mbroeker $
       
     3  * $URL: http://localhost/svn/c/lsflib/trunk/src/bindump.c $
       
     4  *
       
     5  */
       
     6 
       
     7 #include <stdio.h>
       
     8 #include <string.h>
       
     9 
       
    10 char *bindump (char *s, int n)
       
    11 {
       
    12     int i, j;
       
    13     static char byte[8];
       
    14 
       
    15     for (i = 0; i < strlen (s); i++) {
       
    16         for (j = n - 1; j >= 0; j--) {
       
    17             byte[j] = (s[i] >> j) & 1 ? 1 : 0;
       
    18             printf ("%d", byte[j]);
       
    19         }
       
    20         printf ("\n");
       
    21     }
       
    22     return byte;
       
    23 }