wall
This commit is contained in:
40
memory.c
Normal file
40
memory.c
Normal file
@ -0,0 +1,40 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <windows.h>
|
||||
|
||||
int e;
|
||||
static int f;
|
||||
int g = 10;
|
||||
static int h = 10;
|
||||
int main()
|
||||
{
|
||||
SetConsoleOutputCP(65001); // 设置控制台为 UTF-8 编码,配合 #include <windows.h> ,终端输出的就不是乱码
|
||||
int a;
|
||||
int b = 10;
|
||||
static int c;
|
||||
static int d = 10;
|
||||
char* i = "test";
|
||||
char* k = NULL;
|
||||
|
||||
printf("&a\t %p\t // 局部未初始化变量\n", &a);
|
||||
printf("&b\t %p\t // 局部初始化变量\n", &b);
|
||||
|
||||
printf("&c\t %p\t // 静态局部未初始化变量\n", &c);
|
||||
printf("&d\t %p\t // 静态局部初始化变量\n", &d);
|
||||
|
||||
printf("&e\t %p\t // 全局未初始化变量\n", &e);
|
||||
printf("&f\t %p\t // 全局静态未初始化变量\n", &f);
|
||||
|
||||
printf("&g\t %p\t // 全局初始化变量\n", &g);
|
||||
printf("&h\t %p\t // 全局静态初始化变量\n", &h);
|
||||
|
||||
printf("i\t %p\t // 只读数据(文字常量区)\n", i);
|
||||
|
||||
k = (char*)malloc(10);
|
||||
printf("k\t %p\t // 动态分配的内存\n", k);
|
||||
|
||||
system("pause"); //保持终端存在,配合 #include<stdlib.h>
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user