fork download
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. void swap(int *x, int *y)
  5. {
  6. int *tmp = x;
  7. x = y;
  8. y = tmp;
  9. }
  10.  
  11. int main()
  12. {
  13. int u = 10;
  14. int v = 20;
  15. int * p = &u;
  16. int * q = &v;
  17. swap(*p, *q);
  18. std::cout<<"u :-"<<u<<" v :-"<<v<<endl;
  19. return 0;
  20. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
u :-20 v  :-10