//got this code from a book.
Can someone explain this part of code....Code:void dump(const unsigned char *data_buffer, const unsigned int length) { unsigned char byte; unsigned int i, j; for(i=0; i < length; i++) { byte = data_buffer[i]; printf("%02x ", data_buffer[i]); // display byte in hex if(((i%16)==15) || (i==length-1)) { for(j=0; j < 15-(i%16); j++) printf(" "); printf("| "); for(j=(i-(i%16)); j <= i; j++) { // display printable bytes from line byte = data_buffer[j]; if((byte > 31) && (byte < 127)) // outside printable char range printf("%c", byte); else printf("."); } printf("\n"); // end of the dump line (each line 16 bytes) } // end if } // end for }
if(((i%16)==15) || (i==length-1)) {
for(j=0; j < 15-(i%16); j++)
also...
for(j=(i-(i%16)); j <= i; j++) {
Most of this makes sense, it's the i%16 part that's throwing me off.
Any help appreciated.



LinkBack URL
About LinkBacks



