basic-c/sources/swapfunc.c

17 lines
283 B
C

#include <stdio.h>
void swap(char* a, char* b) {
*a ^= *b;
*b ^= *a;
*a ^= *b;
}
int main(int argc, char* argv[]) {
char a = 11;
char b = 15;
printf("a = %d, b = %d", a, b);
swap(&a, &b);
printf("a = %d, b = %d", a, b);
return 0;
}