a3: Sollte jetzt mod 16 sein

This commit is contained in:
Johannes Theiner 2018-11-15 11:03:14 +01:00
parent d3cd764826
commit 8dce0c854b
1 changed files with 12 additions and 1 deletions

View File

@ -2,17 +2,28 @@
#include <stdio.h>
#include <memory.h>
#include <malloc.h>
#include <stdint.h>
void memdump(unsigned char *string) {
printf("ADDR\t\t00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 0123456789ABCDEF\n");
printf("ADDR\t\t\t00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 0123456789ABCDEF\n");
int columns = 16;
int rows = 4;
char symbols[columns * rows];
if((long) string % 16 != 0) {
string = string - ((long) string % 16);
}
for(int i = 0; i < rows; i++) {
printf("%p\t", (void *) &string[i * columns]);//print address
if((long) string % 16 != 0) {
printf("oh nein, kein mod 16");
}
for (int j = i * columns; j < (i + 1) * columns; j++) {
printf("%02x ", string[j]);//print char number
if(string[j] < 0x20 || string[j] > 0x7e)//check for printable characters