My assumption is that compiler changes the address of the variable after every run. (And it does in MSVC)
For some reason, G++ Compiler for me returns the same address every time I run.
- Even after closing and running again, it returns the commented address. Is there any optimization technique I am unaware of?
- After changing variable names too, this returns the same address.
Want to understand the difference between MSVC and G++ and the reason behind it.
#include<iostream>
using namespace std;
int main(){
int b[] = {23,4,6,1,5,7,8,7};
cout << b; //0x61fef0
cout << endl;
cout << &b[0]; //0x61fef0
return 0;
}
Note: I am using g++ (MinGW.org GCC Build-2) 9.2.0