Created
December 25, 2018 10:18
-
-
Save mejariamol/9c9d87ca5497073b1dba07d6b5e01727 to your computer and use it in GitHub Desktop.
code 2 | C++ code to illustrate behind the scene
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
// This method is used to get | |
// pretty addresses. | |
int addr(void * p) { | |
return (long)p%1000; | |
}; | |
int main() { | |
int zeroArr[2]; | |
int i; | |
for (i=0; i<2; i++) { | |
zeroArr[i] = 0; | |
} | |
int oneArr[2]; | |
for (i=0; i<=2; i++) { | |
oneArr[i] = 1; | |
} | |
cout << "zeroArr[1] " << addr(zeroArr+1) << endl; | |
cout << "zeroArr[0] " << addr(zeroArr) << endl; | |
cout << "oneArr[1] " << addr(oneArr+1) << endl; | |
cout << "oneArr[0] " << addr(oneArr) << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment