I am working in Ubuntu 16.04 VM
I have a C program that takes in one argument that is expected to be a hexadecimal number between 0-7ffffffffffffff.
How do I check if the memory address specified is allocated in the virtual memory of my program and access the single byte of memory at the address?
EDIT: so I can see the contents of my mapping via:
FILE *fptr = fopen("/proc/self/maps", "r");
c = fgetc(fptr);
while (c != EOF){
print("%c\n", c);
c = fgetc(fptr);
}
and I'm using the following function: void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset) that returns a pointer to the allocated region
however when I try using the command line argument, I type cast (void *) addr and it changes it to the hex value when I'm to assume that it is already in hex and I don't know how to avoid it unnecessarily converting.