Skip to content

Instantly share code, notes, and snippets.

@kovek
Last active Dec 15, 2015
Embed
What would you like to do?
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