Skip to content

Instantly share code, notes, and snippets.

@blackymetal
Created May 14, 2014 18:49
Show Gist options
  • Save blackymetal/5f2c2c7c548d3671b18e to your computer and use it in GitHub Desktop.
Save blackymetal/5f2c2c7c548d3671b18e to your computer and use it in GitHub Desktop.
swap values
#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