1. 指針變量做爲函數參數、
void sw(int* xingchan1, int* xingchan2)//指針變量做爲形參、 { int c; c = *xingchan1; *xingchan1 = *xingchan2; *xingchan2 = c; printf("c=%d\n", c); }//至關於整型變量賦值 int main() { int a = 2, b = 4; int* a1, *a2;//定義指針變量——整型變量、 a1 = &a; a2 = &b; printf("a=%d,b=%d\n", a, b); if (a < b) { sw(a1, a2);//做爲實參 } printf("a=%d,b=%d\n", a, b); }
函數sw()遵循C語言的規定、實參向形參傳遞的規則、單向的值傳遞、調用sw()沒有改變實參指針變量的值、改變的是實參指針變量所指向的變量、函數