how would i go about editing a pointer indirectly?
i want to give the pointer the address to edit at runtime.
eg. the address of 0x65456 = 15
int* addr;
cin>>addr;
*addr = 20
cout<<*addr
runtime:
input: 0x65456
output: 20
editing a c++ pointer indirectly
Re:editing a c++ pointer indirectly
not sure, but try with a scanf enstead of cin, remember that if u modify pointer address u can get a seg fault.
Re:editing a c++ pointer indirectly
and what are you trying to accomplish?
so you enter some arbitrary address and read/write the value there.
-you may overwrite some arbitrary piece of data and god knows what will happen.
-you may hit an unallocated memory area and the program will crash.
an address has any paricular meaning only within a particular process where it was obtained, and only when you point it to something.
so you enter some arbitrary address and read/write the value there.
-you may overwrite some arbitrary piece of data and god knows what will happen.
-you may hit an unallocated memory area and the program will crash.
Code: Select all
int* addr;
cin>>addr;
*addr = 20
cout<<*addr
Re:editing a c++ pointer indirectly
what i want to do is something like this.
int* whatever = 0x89456;
but this wont work.
int* whatever = 0x89456;
but this wont work.
Re:editing a c++ pointer indirectly
you need to cast it.
Code: Select all
int* whatever = (int *)0x89456;