传入指针参数
1 #include<stdio.h> 2 #include<stdlib.h> 3 void READ(int *a) 4 { 5 scanf("%d",a); 6 } 7 int main() 8 { 9 int a; 10 READ(&a); 11 printf("a=%d ",a); 12 13 int b,*c,*d; 14 scanf("%d",&b); 15 //*c = b; //error,c还未分配空间 16 c = &b;//right, c指向b 17 printf("c = %d ",*c); 18 19 d = (int*)malloc(sizeof(int)); 20 *d = b;//right,已经分配空间 21 printf("d = %d ",*d); 22 23 }