a3: Sollte jetzt mod 16 sein
This commit is contained in:
parent
d3cd764826
commit
8dce0c854b
13
src/c/a3.c
13
src/c/a3.c
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue