Created
October 24, 2016 23:16
-
-
Save hankliu5/d4914851970e4a93e7137a894f31e825 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
void swap(int *x, int *y) { | |
int temp = *x; | |
printf("the value of temp: %d\n", temp); | |
*x = *y; | |
*y = temp; | |
} | |
void wrong_swap(int x, int y) { | |
int temp = x; | |
x = y; | |
y = temp; | |
} | |
int main() { | |
int i = 10, j = 20; | |
printf("Before Swapping\n%d %d\n", i, j); | |
swap(&i, &j); | |
printf("After Swapping\n%d %d\n", i, j); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment