stack auto variable. and struct variable.
来源:互联网 发布:ubb源码下载 编辑:程序博客网 时间:2024/05/03 13:18
#pragma pack(4)
Typedef struct Test_STRUCT
{
Char DataOne;
Long DataTwo;
Short DataThree;
Int DataFour;
};
Int main(int argc,char *agrv[])
{
Test_STRUCT ts;
Int a;
Long b;
Char c;
Printf(“%d/n”,sizeof(ts));
Flag1: a= 0x12345678; b= 0x12345678; c= 0x12;
Ts.DataOne = 0x12;
Ts.DataTwo = 0x12345678;
Ts.DataThree = 0x1234;
Ts.DataFour = 0x12345678;
Flag2: memset(&b,0x44,5);
Flag3: memset(&ts,c,5);
Flag4: memset(&c,0x33,5);
Flag5: printf(“0x%x, 0x%x, 0x%x, 0x%x/n0x%x, 0x%x, 0x%x/n”,a,b,c,ts.DataOne,ts.DataTwo,ts.DataThree,ts.DataFour);
Return 0;
}
1、#pragma pack(4)是什么意思?
2、 程序运行到flag1,显示什么?
3、 程序运行到flag2,c为多少?
4、 程序运行到flag3,ts 每一个成员的值分别是什么?
5、 程序运行到flag4,程序会崩溃吗?为什么?
6、 若程序没有崩溃,flag5语句会在屏幕上打印出什么?
分析:
1:栈上的变量,按声明顺序,由高地址到低地址。
2:struct的成员变量,按声明顺序,由低地址到高地址。
结果。
x12345644, 0x44444433, 0x33, 0x12
0x12345612, 0x1234, 0x12345678
- stack auto variable. and struct variable.
- Auto variable in C++
- global variable and local variable
- stack around the variable variable was corupted
- Static Variable, Auto Variable, Global Variable, Local Variable, Register Variable (C)
- Variable
- Variable
- variable
- variable
- Debug**struct as local variable
- stack around variable was corrupted
- globe variable and local variable testing
- Java static variable and static final variable
- Variable and Constant
- Variable and basic type
- thread and share variable
- static function and variable
- distinguish between variable and field
- 结构型模式——代理复习
- oracle管道化表函数
- perl找出文本行中的注释
- ORACLE OVER ,取出按条件分组的首记录
- 存储过程-获取连接SQL服务器的信息
- stack auto variable. and struct variable.
- autoconf和automake的安装与使用
- JSP防SQL注入攻击
- 中国移动飞信的研究 笔记一
- TCPMP源代码编译
- CSDN 家园开张
- TCPMP源代码分析
- 如何注册公司
- 界面与后台工作线程分离的方案