数值传递和指针传递0618

 1 #include <stdio.h>
 2 #include <malloc.h>
 3 #include "string.h"
 4 /* 数值传递 */
 5 void test1(int **ppint)
 6 {
 7     int *pint=(int *)malloc(sizeof(int)*100);//为什么在这里会报错
 8     ppint=&pint;
 9 
10 }
11 /*  指针传递 */
12 void test(int **ppint)
13 {
14     int *pint=(int *)malloc(sizeof(int)*100);//这里却能正常赋值,是不是对二级指针理解有问题?
15     *ppint=pint;
16 
17 }
18 
19 int main()
20 {
21     /* 数值传递 */
22     int **ppdata=NULL;
23     test1(ppdata);
24     /* 指针传递 */
25     //int *ppdata=NULL;
26     //test(&ppdata);
27     printf("%p",ppdata);
28     return 0;
29 
30 }

 

posted @ 2017-06-18 10:23  cheshulin  阅读(241)  评论(0编辑  收藏  举报