You have the following C++ function.
void foo() {
int a = 10;
if (true) { int b = 20; }
int c = 30;
cout << &a << “ “ << &c << endl;
}
When you call it, it prints the following output:
0x00000000abcabcab 0x00000000abcabcb3
Assuming that type int takes 4 bytes in memory, what do you think the address of b will be? :
- 0x00000000abcabcaf
- 0x00000000abcabca7
- 0x00000000abcabcb7
- There is no address for b because it is allocated on the heap.