Skip to content

Instantly share code, notes, and snippets.

@kovek
Last active December 15, 2015 06:39
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save kovek/5217935 to your computer and use it in GitHub Desktop.
A test I made. The setup: Windows 7 32 bit I ran the code using MinGW using Cod::Blocks I was just trying to see how arrays behaved. When I add 3 or 4 on line 9 there is other behavior that I do not understand, but not as weird as this message: http://pastebin.com/K0HAL5nJ.
#include <iostream>
using namespace std;
int main()
{
string foo[3] = {"a", "b", "c"};
cout << &foo[0] << " minus " << &foo[1] << " equals " << int(&foo[0])-int(&foo[1]) << endl;
cout << *(&foo[0]-4) << endl;
cout << "Hello world!" << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment