This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Dec 14th, 2010  |  syntax: C++  |  size: 0.36 KB  |  views: 22  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. int i, x, a[2];
  2.  
  3. void q(int b)
  4. {
  5.   // here you have: a = [1, 2], and b = 1 from the call
  6.  
  7.   a[0] = 2; // now: a = [2, 2]
  8.  
  9.   i = 1;
  10.  
  11.   x = b+a[i]; // x = 1 + a[1] = 1 + 2 = 3
  12.  
  13.   b = a[0]; // b = 2 but forgot because it's local to the function
  14. }
  15.  
  16. void main()
  17. {
  18.   i = 0;
  19.   a[0] = 1;
  20.   a[1] = 2;
  21.  
  22.   // a[i] = a[0] = 1, so: q(1)
  23.   q(a[i]);
  24. }
clone this paste RAW Paste Data