Skip to content

Instantly share code, notes, and snippets.

@joffilyfe
Created April 29, 2015 13:09
Show Gist options
  • Save joffilyfe/65e97dc7407a25423ea7 to your computer and use it in GitHub Desktop.
Save joffilyfe/65e97dc7407a25423ea7 to your computer and use it in GitHub Desktop.
troca!
#include <stdio.h>
void troca(int *x, int *y);
int main(void) {
int x, y;
x = 10;
y = 20;
troca(&x, &y);
printf("X: %d\n", x);
printf("Y: %d\n", y);
return 0;
}
void troca(int *x, int *y) {
int aux;
aux = *y;
*y = *x;
*x = aux;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment