使用监视器查看变量,使用内存读取内存地址和值
- 步骤
- 首先设置断点—-打开调试
- 监视栏输入取地址符以及变量名
- 将内存地址拖拽到内存区域,顶部第一行显示即为变量的值
- 调试栏选择下一条语句,变量 a 的值改变【 3—-> 5】
- 示意图

- code
#include <stdio.h>#define PI 3 /* 符号常量 */int main() {int a = 3; /* 一个变量 */a = 5; /* *///PI = 10;printf("%d\n", PI);}
字符常量
直接打印,可得其输出

Scanf函数使用时报错
- 原因
不安全的函数
- 错误样式

- 解决方案
添加如下宏定义
_CRT_SECURE_NO_WARNINGS
int main() { int a; / 一个变量 / scanf(“%d”, &a); / 一定要在变量前加入 & 符号 / printf(“a = %d\n”, a); }
5. 细节[通过将 scanf获取到的值赋值给一个变量,取消绿色波浪线标记]6. 同时获取多个值的输入```c#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>int main() {int a, b, ret; /* 一个变量 */ret = scanf("%d%d", &a, &b); /* 一定要在变量前加入 & 符号 */printf("a = %d, b = %d\n", a, b);}
int main() { int a, b, ret; / 一个变量 / ret = scanf(“%d%d”, &a, &b); / 一定要在变量前加入 & 符号 / printf(“%d\n”, a + b); }
8. 细节 --- 小端表示内存地址 ---- 低位在前9. 1<a name="Pl0mQ"></a>## 以十进制输出某个整数code```c#include <stdio.h>#include <stdlib.h>int main() {//int i = 123;int i = 0x7b;printf("%d\n", i); /* 以十进制输出某一个整型数 */}

位与字节
1 Byte = 8 bit
- 进程地址空间
所谓进程地址空间(process address space),就是从进程的视角看到的地址空间,是进程运行时所用到的虚拟地址的集合。
- 内存上限【以int 4字节为例】

输出浮点数
int main() { float f = 1.234; printf(“%f\n”, f); / 以浮点数形式输出 / return 0; }
2. 科学计数法```c#include <stdio.h>#include <stdlib.h>int main() {float f = 3e3;printf("%f\n", f); /* 以浮点数形式输出 */return 0;}

浮点数空间占用—-四个字节
单目操作符: sizeof()获取变量占用字节的大小
code
#include <stdio.h>#include <stdlib.h>int main() {float f = 3e3;printf("%f\n", f); /* 以浮点数形式输出 */return 0;}

字符类型
code1
#include <stdio.h>#include <stdlib.h>int main() {float f = 3e3;printf("%f\n", f); /* 以浮点数形式输出 */char c = 'a';printf("%c\n", c); /* 以字符形式输出 */return 0;}
code2
#include <stdio.h>#include <stdlib.h>int main() {float f = 3e3;printf("%f\n", f); /* 以浮点数形式输出 */char c = 'a';printf("%c\n", 97); /* 以字符形式输出 */return 0;}



