一,指针的*与++的联合应用
注意:*p++
和++*p
和*++p
是不同的概念
#include<stdio.h>
int main()
{
const int a = 5;
int ar[a] = {11,21,31,41,51};
int* p = ar;
int x = 0, y = 0;
x = *p++;
y = *p;
printf("%d ",x);//11
printf("%d ",y);//21
x = ++ * p;
y = *p;
printf("%d ", x);//22
printf("%d ", y);//22
x = *++p;
y = *p;
printf("%d ", x);//31
printf("%d ", y);//31
return 0;
}
**二,**通过代码来发现内存是小端存放还是大端存放
#include<stdio.h>
int main()
{
short a = 0x0001;
char* p = (char*)&a;
if (*p == 1)
{
printf("小端存放%p %p\n",p,p+1);
}
else printf("大端存放%p %p\n",p,p+1);
return 0;
}