MIPI_BaseC_WebinarFRTK/25_Seminar12/05_macros_swap_2_p15.c

15 lines
233 B
C
Raw Normal View History

2024-11-13 09:22:28 +03:00
#include <stdio.h>
#define SWAP(type,a,b) do{type t = a; a = b; b = t;}while(0)
int main(void)
{
int a=5, b=7;
if(a<b)
SWAP(int, a,b);
else
a = 1000;
printf("a = %d b = %d\n", a, b);
return 0;
}