I sm trying to scan a system's memory.
My plan :
Create pointers to point to memory,
And move this pointer up one byte each loop.
So this is what i came up with :
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
const char *MemAdressPointer(int n);
int main(void) {
int i = 0;
for(i = 0; i<100; i++)
{
const char* pAddr = MemAdressPointer(i+5000);
printf("%c hexadecimal value of : 0x%p with i at : %i
", *pAddr, pAddr, i);
}
getchar();
return 0;
}
const char *MemAdressPointer(int n)
{
void *p1 = (void*) n;
const char* p2;
p2 = p1;
return p2;
}
Everything, at least that i know of, works.
It prints the good memory address.
But when i print the character (%c) it just stops responding
It is weird, the pointer, being a character,
shouldn't it point to one byte and get this byte's binary value
and get the corresponding character out of it.
Thanks for any help you can give me.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…