Skip to content

Instantly share code, notes, and snippets.

@jeffcrouse
Created November 2, 2013 21:11
Show Gist options
  • Select an option

  • Save jeffcrouse/7283559 to your computer and use it in GitHub Desktop.

Select an option

Save jeffcrouse/7283559 to your computer and use it in GitHub Desktop.
compile with g++ -o blocks blocks.cpp
#include <iostream>
using namespace std;
int main ()
{
int foo[4];
double bar[4];
// Print out the memory addresses of all 4 elements of "foo"
for(int i=0; i<4; i++)
{
cout << "&foo[" << i << "] = " << &foo[i] << endl;
}
// Do the same for "bar" -- notice that "bar" is doubles
for(int i=0; i<4; i++)
{
cout << "&bar[" << i << "] = " << &bar[i] << endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment