- 函数中的传出参数要通过地址进行传出
- 例子:
#include<stdio.h>
#include<stdlib.h>
int func(int n1,int *n2,int **n3)
{
n1 = 1;
//变量不能作为传出参数,传出参数只能是指针类型的(通过地址传出)
//此时可以有多个返回值
*n2 = 2;
**n3 = 3;
printf("in func---> n1 = %d,*n2 = %d,**n3 = %d\n",n1,*n2,**n3);
return n1;
//变量只能通过return传出来
}
int main()
{
int n1 = 11,n2= 22,*n3;
n3 = (int *)malloc(sizeof(int));
*n3 = 33;
printf("before func------> n1 = %d,n2 = %d,*n3 = %d\n",n1,n2,*n3);
n1 = func(n1,&n2,&n3);
printf("out finc-----> n1 = %d,n2 = %d,*n3 = %d\n",n1,n2,*n3);
free(n3);
return 0;
}