传入指针参数

 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\n",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\n",*c);
18 
19         d = (int*)malloc(sizeof(int));
20         *d = b;//right,已经分配空间
21         printf("d = %d\n",*d);
22 
23 }

 

相关文章:

  • 2021-10-09
  • 2022-12-23
  • 2021-05-18
  • 2022-12-23
  • 2021-09-02
  • 2021-05-30
  • 2022-12-23
  • 2021-12-02
猜你喜欢
  • 2022-12-23
  • 2021-06-26
  • 2021-10-01
  • 2022-12-23
  • 2021-10-29
  • 2022-12-23
相关资源
相似解决方案