c指针5

来源:互联网 发布:js中日期时间格式化 编辑:程序博客网 时间:2024/06/02 00:14
int* arr=[5]={0};arr[0]=(int*)10;
arr[1]=(int*)10;
arr[2]=(int*)10;
arr[3]=(int*)10;
arr[4]=(int*)10;


int a = 10;mov dword ptr[ebp-4],0Ahint b = 20;mov dword ptr[ebp-8],14hint c = 30;mov dword ptr[ebp-0Ch],1Ehint d = 40;mov dword ptr[ebp-10h],28hint e = 50;move dword ptr[ebp-14h],32hint* arr[5] ={&a,&b,&c,&d,&e}lea eax,[ebp-4]mov dword ptr[ebp-28h],eaxlea ecx,[ebp-8]mov dword ptr[ebp-24h],ecxlea edx,[ebp-0Ch]mov dword ptr[ebp-20h],edxlea eax,[ebp-10h]mov dword ptr[ebp-1Ch],eaxlea ecx,[ebp-14h]
struct Atr{  int  a;  int  b;  int  c;}


mov dword ptr[ebp-18h],ecx

指针数组:

char* keyword[]={"if","for","while","switch"}; mov dword ptr[ebp-10h],offset string "if"(常量区地址)  mov dword ptr[ebp-1Ch],offset string "%s\n"(常量区地址)  mov dword ptr[ebp-18h],offset string "while"(常量区地址)  mov dword ptr[ebp-14h],offset string "china"(常量区地址)
结构体指针:

struct Arg{  int a;  int b;  int c;}Arg* pArg;pArg=(Arg)100;

反汇编代码都差不多,为什么有这么多类型:运算不一样,方便编译器。

pArg =(Arg*)100;
pArg=pArg+5;
printf("%d\n",pArg);
//输出结果为160 100+3*4*5

pArg2 =(Arg*)20;
int x = pArg-pArg2;//同类型指针运算 结果为int类型。 汇编代码为 100-20/12 =6 idiv 50h,0ch;

Arg s;
s.a = 10;
mov dword ptr[ebp-0ch],0Ah
s.b = 20;
mov dword ptr[ebp-8],14h
s.c = 30;
mov dword ptr[ebp-4],1Eh

Arg* px = &s;
lea eax,[ebp-0ch]
mov dword ptr[ebp-10h],eax

px->a //->结构体指针操作->编译器看这个就是这个地址的a的值
printf("%d\n",px->a)

struct Arg{
int a;
charb;
short c;
}

px->a=100;
px->b=200;//char溢出越界-56
px->c=300;


int x =10;
Arg* px = (Arg*)&x;//编译通过,
px->a 取值为10,后面不知道是什么玩意,就是指向一个地址,安定义的字节取值哈哈。运气好能看到值,运气不好005错误,噫
//10 00 00 00 xxxxxxxxxx





原创粉丝点击