Created
March 16, 2025 02:32
-
-
Save hamza-cskn/aa1fb6c8c8c0e4c1a7356288e3c53898 to your computer and use it in GitHub Desktop.
memory debugger.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void z(char c,int n){while (n--> 0)printf("%c",c);}void y(void *q,int k){while(k-->0)if(*(unsigned char*)q>=32&&*(unsigned char*)q<=126)printf("%c ",*(unsigned char*)q++);else printf(". ");}void x(void *q,int k){while(k-->0)printf("%02x ",*(unsigned char*)q++);}void print_memory(void *q,int k){unsigned char*mem=(unsigned char*)q;int n,d=8,f=0;while(f<=k/d){n=d<k-f*d?d:k-f*d;printf("%p: ",mem);x(mem,n);z(' ',(d - n)*3);printf("-> ");y(mem, n);printf("\n");mem += n;f++;}} |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
print_memory(addr, size)