So, I'm having a bit of pointer issues. I'm writing a function that stores memory addresses in a[]. These memory addresses point to actual data values in b[]. I'm having trouble getting the memory address from b to store in a.
// Assume these are initialized to 0 outside of this snippet
char a[100];
char b[100];
b[0] = 42; // Some value for us to use
int* a_ptr = (int*)&a[0]; // Store the address of a[0] in a_ptr
int* b_ptr = (int*)&b[0]; // Store the address of b[0] in b_ptr
*a_ptr = (int)&b_ptr; // PROBLEM LINE. The first four bytes of a[]
// should contain the memory address of b[0].
// However, it does not. Here are the debugger values:
// a_ptr = 0x00429148
// b_ptr = 0x00429151
// a[0] SHOULD be 0x00429151, but it is instead 0x0012fe4c.
Is there some trick I need to do to get 0x00429151 to be stored at a[0..3]?