lsflib/src/bindump.c
author Markus Bröker <mbroeker@largo.dyndns.tv>
Thu, 16 Apr 2009 12:47:59 +0200
changeset 29 7abf6146898e
parent 9 c3fecc82ade6
child 77 49e0babccb23
permissions -rw-r--r--
indent -bad changed to -nbad: See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=485764 committer: Markus Bröker <mbroeker@largo.homelinux.org>

/**
 * test/demos/lsflib/src/bindump.c
 * Copyright (C) 2008 Markus Broeker
 */

#include <stdio.h>
#include <string.h>

char *bindump (char *s, int n)
{
    int i, j;
    static char byte[8];

    for (i = 0; i < strlen (s); i++) {
        for (j = n - 1; j >= 0; j--) {
            byte[j] = (s[i] >> j) & 1 ? 1 : 0;
            printf ("%d", byte[j]);
        }
        printf ("\n");
    }
    return byte;
}