#include <stdio.h>
//定義函數(shù),什么情況需要定義指針參數(shù)
void test(int *c,int d){
*c=d;
}
int main(){
int a=1;
int b=2;
printf("之前:%d\n",a);
test(&a,b);
printf("之后:%d",a);
return 0;
}
原本test函數(shù)里的變量無(wú)法影響main函數(shù)里的變量,但是因?yàn)槭褂昧酥羔槪瑢?dǎo)致main函數(shù)的變量改變了。

QQ截圖20191206145613.png