Correct me if I'm wrong. An array is a pointer to sequential blocks of memory that hold the same data type. You cannot write an entire array to a single pointer. You can print the address of the array, but not it's contents all at once
Ok, now how would i check to see if the variable in the memory address has been changed? i was trying to compare them and see if it changed at all so one would have the initial var and the other would hold the changed version. i did this i think this is what i want:
so how would i check to see if the value has been changed? i used cheat engine to modify the value of 900 and changed it to 7 but the output still said that it was the same.
A pointer to the memory address is not sufficient enough to detect a change in the information being pointed to. Because a pointer just "points" whenever a change is made to the value at that memory address, the address of the pointer is still the same as that of the object. You will need a second variable to store the value the pointer is pointing to in order to detect a change in the variable:
1 2 3 4 5 6 7 8 9 10 11 12
#include <cstdio>
int main() {
int number = 900, number2, *p_address = &number;
printf("Address of p_address = %p\n", p_address);
printf("Address of number = %p\n", &number);
number2 = *p_address; //Store initial value held by the pointer
number = 901;
if (number2 != *p_address) puts("value changed!");
if (number2 == *p_address) puts("value still the same");
return 0;
}
#include <iostream>
int main(void) {
int number = 900, number2, *p_address = &number;
std::cout << "Address of p_address = " << p_address << '\n';
std::cout << "Address of number = " << &number << '\n';
number2 = *p_address; //Store initial value held by the pointer
number = 901;
if (number2 != *p_address) std::cout << "value changed!\n";
elseif (number2 == *p_address) std::cout << "value still the same\n";
return 0;
}