Skip to content

Instantly share code, notes, and snippets.

@asgrim
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asgrim/1d6599c7cd28bee859b4 to your computer and use it in GitHub Desktop.
Save asgrim/1d6599c7cd28bee859b4 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int main()
{
int v;
int *ptr = &v;
*ptr = 15;
ptr++;
ptr++;
*ptr = 10;
cout << "V is " << v << endl;
cout << "ptr " << ptr << endl;
cout << " is " << *ptr << endl;
return 0;
}
@nsitbon
Copy link

nsitbon commented Mar 3, 2015

Q1) right
Q2) should is not the correct term, what you have here is an undefined behaviour, nothing is specified on what should happen in this case.

@asgrim
Copy link
Author

asgrim commented Mar 3, 2015

Thank you both :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment