When I run the following program in VC ++ 2008 Express, I get the difference in location between two sequentially stored integers as "12" instead of the expected "4". In any other compiler, the answer is "4". Is there a special reason why "12"?
#include <iostream> using namespace std; int main() { int num1, num2; cin >> num1 >> num2; cout << &num1 << endl << &num2 << endl; cout << int(&num1) - int(&num2)<<endl; //Here it shows difference as 12. cout << sizeof(num1); //Here it shows the size as 4. return 0; }
source share