C Programming
swap3.c(전역변수 사용)
빛하루
2023. 8. 4. 09:34
#include <stdio.h>
int a,b; // global var(전역변수) -> 모든 함수들이 접근 할 수 있는 변수
void swap(void) {
int tmp = a; // local var(지역변수)
a = b;
b = tmp;
}
int main(void)
{
a = 100;
b = 200;
printf("a : %d\tb:%d\n",a,b);
swap();
printf("a :%d\tb :%d\n",a,b);
return 0;
}