内存四区代码演示
作者:互联网
栈:
#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 */
标签:p2,p1,演示,四区,hellow12345,char,内存,return,include 来源: https://www.cnblogs.com/zhjblogs/p/15007683.html