Sunday, 11 November 2012

Week11_void bitDump(void* memAddress, unsigned int memSize)

By given memory address and the size, output what the given memory has on the screen:

void bitDump(void* memAddress, unsigned int memSize) {
    unsigned char* p = (unsigned char*) memAddress;
    int i;
    for (i=0; i < memSize; i++) {
        unsigned int n = 1 << (sizeof(p)*8 -1);
        while(n) {
            printf("%c", !!(p[i] && n));
            n = n >> 1;
        }
    }//end forloop
}

No comments:

Post a Comment