I’m trying to figure out the answer to this question with the following code, but it turns out, the value of the pointer (address of problem3 turned out to be so far away from the parameter and local variables of the function) where the hell is x = problem3; pointing to…
void problem3(int a) {
int overflowme[16];
int x = problem3;
overflowme[15] = 102;
printf(" the address of x is %x\n the addres of the first local is %x\n the addres of the first para is %x\n ", x, &overflowme[15], &a);
}
int main(void) {
problem3(101);
}
OUTPUT
the address of x is 42b613
the addres of the first local is 12fed8
the addres of the first para is 12fee4
Press any key to continue . . .
Because problem3 is a function pointer (i.e. the memory address of a function) and all pointers can be cast to integers.
No. However you could do that, if you wanted to (by doing
x = (int) "hello world";) because “hello world” is also a pointer (a char pointer to be precise), so the above applies.