内存四区代码演示

栈:

#define  _CRT_SECURE_NO_WARNINGS 
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

char *pMem1()
{
    char *p1 = "hellow12345";
    return p1;
}
//函数调用完毕后,函数内部的栈区变量就会被销毁

char *pMem2()
{
    char *p2 = "hellow12345";
    return p2;
}

int main(void)
{
    char *p1 = NULL;
    char *p2 = NULL;
    p1 = pMem1();
    p2 = pMem2();
    printf("p1 = %s, p1 = %p\n", p1, p1);
    printf("p2 = %s, p2 = %p\n", p2, p2);
    return 0;

}

/*
输出结果:
p1 = hellow12345, p1 = 00C57BAC
p2 = hellow12345, p2 = 00C57BAC
*/

 

内存四区代码演示

上一篇:IntelliJ IDEA 下载和激活


下一篇:vue + element初始化项目--代码初始化