//指针加法
//指针+1:加一个单元格
//指针+数字:需要调整,调整的权重为sizeof(指针去掉一个*)
//指针全部为4个字节(1级指针,2级指针。。。)
/*#include<stdio.h>
int main()
{
int *p=(int *)2000;
printf("%d\n",p+4);//2016 int型指针为4字节
printf("%d\n",(short*)p+4);//2008去掉一个*为short型,2个字节
printf("%d\n",(double*)p+4);//2032去掉一个*为double型,8个字节
printf("%d\n",(float**)p+4);//2016去掉一个*为float型指针,为4个字节
printf("%d\n",(unsigned short*)p+4 );//2008去掉一个*为unsigned short型,2字节
printf("%d\n",(long*)p+4);//2016去掉一个*为long型,4字节
printf("%d\n",(char*)p+4);//2004char型,1字节
printf("%d\n",(unsigned long long)p+4);//2004常量,直接加4
return 0;
}*/
//指针-数字:需要调整
/*#include<stdio.h>
int main()
{int *p=(int *)0x2010;
printf("%x\n",p-2);//2008
printf("%x\n",(short *)p-2);//200c 2010-4 因为是16进制数,借1当16减4等于12=c
printf("%x\n",(unsigned long*)p-2);//2008
printf("%x\n",(long long **)p-2);//2008
printf("%x\n",(float *)p-2);//2008
printf("%x\n",(double *)p-2);//2000
printf("%x\n",(char *)p-2);//200e
printf("%x\n",(unsigned long)p-2);//200e
return 0;
}*/
//指针-指针:1、算出字节 2、除以调整的权重
/*#include<stdio.h>
int main()
{
int arr[10]={1};
int *p=&arr[1];
int *q=&arr[9];
printf("%d\n",p-q);//-8
printf("%d\n",q-p);//8
printf("%d\n",(short*)q-(short*)p);//16 用一开始定义的类型的字节数计算,除以调整以后的类型字节数
printf("%d\n",(double*)q-(double*)p);//4 int型q-p=32 除以double型字节8==4
printf("%d\n",(int***)q-(int***)p);//8
printf("%d\n",(char**)q-(char**)p);//8
printf("%d\n",(long)q-long(p));//32 常量直接用int型做运算
}*/
//指针的所有运算都需要调整,调整的权重为sizeof