-
-
[原创]献给新手——用一段代码来揭示新手对于堆栈的认识——本文需要新手用OD调试慢慢体会,高手不要浪费时间于此,真心希望像我一样的新手对于堆栈的认识不再茫然,欢迎批评指正
-
发表于:
2012-3-31 12:59
5497
-
[原创]献给新手——用一段代码来揭示新手对于堆栈的认识——本文需要新手用OD调试慢慢体会,高手不要浪费时间于此,真心希望像我一样的新手对于堆栈的认识不再茫然,欢迎批评指正
记得要用debug方式编译,这样会有符号名,顺序也不会乱,编译好后用OD调试,什么?不会用OD?建议去看海绵宝宝。
#include<stdio.h>
#include<malloc.h>
#include<iostream>
using namespace std;
int GlobalVariable1,GlobalVariable2,GlobalVariable3,GlobalVariable4=0xF1,GlobalVariable5=0xF2;
char GlobalVariable6,GlobalVariable7,GlobalVariable8,GlobalVariable9='b',GlobalVariable10='B';
void main()
{
int LocalVariable1,LocalVariable2,LocalVariable3,LocalVariable4=0xF3,LocalVariable5=0xF4;
double LocalVariable6,LocalVariable7,LocalVariable8,LocalVariable9=0.3,LocalVariable10=3;
float LocalVariable11,LocalVariable12,LocalVariable13,LocalVariable14=0.3,LocalVariable15=3;
char LocalVariable16,LocalVariable17,LocalVariable18,LocalVariable19='a',LocalVariable20='A';
static int StaticLocalVariable1,StaticLocalVariable2,StaticLocalVariable3,StaticLocalVariable4=0xF5,StaticLocalVariable5=0xF6;
char StringVariable1[]="StringVariable1",*pStringVariable1="StringVariable2";
const char StringVariable2[]="StringVariable2",*pStringVariable2;
pStringVariable1 = "ConstVariable";
pStringVariable1 = StringVariable1;
pStringVariable2 = StringVariable2;
pStringVariable1 = "StringVariable1";
pStringVariable1 = "GlobalVariable";
GlobalVariable1 = 1;
GlobalVariable2 = 2;
GlobalVariable3 = 3;
GlobalVariable4 = 4;
GlobalVariable5 = 5;
GlobalVariable6 = 1;
GlobalVariable7 = 2;
GlobalVariable8 = 3;
GlobalVariable9 = 4;
GlobalVariable10 = 5;
pStringVariable1 = "StaticLocalVariable";
StaticLocalVariable1 = 1;
StaticLocalVariable2 = 2;
StaticLocalVariable3 = 3;
StaticLocalVariable4 = 4;
StaticLocalVariable5 = 5;
pStringVariable1 = "LocalVariableInt";
LocalVariable1 = 1;
LocalVariable2 = 2;
LocalVariable3 = 3;
LocalVariable4 = 4;
LocalVariable5 = 5;
pStringVariable1 = "LocalVariableDouble";
LocalVariable6 = 1;
LocalVariable7 = 2;
LocalVariable8 = 3;
LocalVariable9 = 4;
LocalVariable10 = 5;
pStringVariable1 = "LocalVariableFloat";
LocalVariable11 = 1;
LocalVariable12 = 2;
LocalVariable13 = 3;
LocalVariable14 = 4;
LocalVariable15 = 5;
pStringVariable1 = "LocalVariableChar";
LocalVariable16 = 1;
LocalVariable17 = 2;
LocalVariable18 = 3;
LocalVariable19 = 4;
LocalVariable20 = 5;
void *i,*j;
i = malloc(1);
j = new char;
free(j);
delete[] i;
i = j = NULL;
}
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!