finished chapter 04

master
Tibor Bizjak 2023-07-14 13:31:34 +02:00
parent 849a032150
commit a408616dcf
1 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1,18 @@
#include <stdio.h>
#define swap(T, x, y) \
do { \
T temp; \
temp = x, x = y, y = temp; \
} while (0)
/* swap x and y */
int main()
{
int x, y;
x = -1, y = 1;
printf("x = %d, y = %d\n", x, y);
swap(int, x, y);
printf("x = %d, y = %d\n", x, y);
return 0;
}