C語言單片機中變量的位置

原文鏈接:https://blog.csdn.net/youyou519/article/details/82701083

int a = 0; 
char *p1; 
static int x = 10;
int main(void) 

    int b = 0; 
    char s1[] = "123"; 
    char *p2; 
    char *s2 = "123"; 
    static int c =0; 
    p1 = (char *)malloc(128); 
    p2 = (char *)malloc(256); 
    free(p1); 
    free(p2); 
    return 0; 

靜態區 
.data:全局初始化的變量 
.bss:全局未初始化變量 
.rdata:全局只讀

全局變量同一個文件中先定義先初始化,不同不確定

轉載作者https://blog.csdn.net/youyou519/article/details/82701083

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