MIPI_BaseC_WebinarFRTK/25_Seminar12/04_macros_swap_p13.c
2024-11-14 08:39:22 +03:00

16 lines
289 B
C

#include <stdio.h>
#define SWAP(type,a,b) do {type a##1 = a; a = b; b = a##1;}while(0)
int main(void)
{
int a=5, t=7;
printf("a = %d b = %d\n", a, t);
if (a<t)
SWAP(int, a,t);//{...}
else
a = 1000;
printf("a = %d b = %d\n", a, t);
return 0;
}