Can I Allocate a specitic memory address using pointers in c++ ?
For example: Allocate This memory address 25D4C3FA and put 4 in it.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Allocating a specific address in your process’s address space is a bit tricky and platform-specific. On Unix systems,
mmap()is probably the closest you’re going to get. The Windows equivalent isVirtualAlloc(). There are, of course, no guarantees since the address might already be in use.Writing to a specific address is trivial:
I assume you have good reasons to want to do that.