Coding/C
[C] 포인터 8 포인터와 함수
0w0
2016. 9. 5. 07:04
728x90
반응형
//call-by-reference
//주소를 인자로 넘기고 포이터를 매개변수로 받습니다.
#include<stdio.h>
void print_test(int a, int b){
printf(" a = %d b = %d \n\n",a,b);
}
void swap_test(int *a, int *b){
int temp=0;
temp=*a;
*a=*b;
*b=temp;
}
int main(){
int a=100;
int b=200;
print_test(a,b);
swap_test(&a,&b);
print_test(a,b);
return 0;
}
728x90
반응형