內存分配

這裏寫圖片描述
代碼

  1 #include<stdio.h>
  2 #include<stdlib.h>
  3 int globle=1000;
  4 int g;
  5 void main ()
  6 {
  7     struct student
  8     {
  9         int num;
 10         struct student *next;
 11     }student;
 12     int b=0;
 13     int *ml;
 14     ml=(int *)malloc(sizeof(int));
 15 
 16     static int c;
 17     static int cd=12;
 18     struct student *a;
 19     printf("局部變量結構體a=%x\n",&a);
 20     printf("局部變量b=%x\n",&b);
 21     printf("結構體成員a->num=%x\n",&(a->num));
 22     printf("malloc動態分配的ml=%x\n",ml);
 23     printf("未初始化的全局變量g=%x\n",&g);
 24     printf("靜態局部變量c=%x\n",&c);
 25     printf("靜態初始化局部變量=%x\n",&cd);
 26     printf("初始化的全局變量globle=%x\n",&globle);
 27 
 28     free(ml);
 29 }

運行結果:
這裏寫圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章