Files
2026-03-22 17:40:44 +08:00

20 lines
347 B
C

#include <stdio.h>
#define swaps(type, a, b) do { type tmp = a; a = b; b = tmp; } while(0)
void swap(int *a, int *b) {
int tmp = *a;
*a = *b;
*b = tmp;
}
int main() {
int a = 69, b = 31;
printf("%d, %d", a, b);
swap(&a, &b);
printf("Function Swap: %d, %d\n", a, b);
swaps(int, a, b);
printf("Macro Swap: %d, %d\n", a, b);
return 0;
}