Skip to content

Instantly share code, notes, and snippets.

@justinrixx
Created May 5, 2015 19:19
Show Gist options
  • Save justinrixx/162186c463ceca58abbd to your computer and use it in GitHub Desktop.
Save justinrixx/162186c463ceca58abbd to your computer and use it in GitHub Desktop.
A cool hack exposed in the C++ compiler (works with GCC, at least).
#include <iostream>
using namespace std;
int main()
{
int x;
int y;
cout << "Enter x: ";
cin >> x;
cout << "Enter y: ";
cin >> y;
cout << "x: " << x << endl
<< "y: " << y << endl;
cout << endl << "x = x + y - (y = x)" << endl << endl;
x = x + y - (y = x);
cout << "x: " << x << endl
<< "y: " << y << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment