Created
May 14, 2014 18:49
-
-
Save blackymetal/5f2c2c7c548d3671b18e to your computer and use it in GitHub Desktop.
swap values
This file contains hidden or 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 <stdio.h> | |
#include <string.h> | |
void swap(int *, int *); | |
main() { | |
int px, py; | |
px = 1; | |
py = 2; | |
printf("%d %d\n", px, py); | |
swap(&px, &py); | |
printf("%d %d\n", px, py); | |
} | |
void swap(int *px, int *py) { | |
int temp; | |
temp = *px; | |
*px = *py; | |
*py = temp; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment