Skip to content

Instantly share code, notes, and snippets.

@zenatureza
Created January 12, 2014 21:41
Show Gist options
  • Save zenatureza/8390940 to your computer and use it in GitHub Desktop.
Save zenatureza/8390940 to your computer and use it in GitHub Desktop.
#include <stdlib.h>
#include <stdio.h>
void troca(int *a, int *b);
void main(){
int x, y;
printf("Insira dois números:\n");
scanf("%d", &x);
getchar();
scanf("%d", &y);
int *px = &x, *py = &y;
troca(&x, &y);
printf("Os valores invertidos são: %d e %d", x, y);
}
void troca(int *a, int *b){
int temp;
temp = *a;
*a = *b;
*b = temp;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment