学如逆水行舟不仅则退
今天老板写了一篇文章让我帮忙校验一下,于是我就有了下面的代码标题的感悟
#include <stdio.h>
typedef unsigned char uchar;
int main(void)
{
int i, *ip = &i;
printf("i的地址空间是:%p\n",ip);
uchar a,b,c,d,e,f,g,h,x,y,z;
uchar niu[12] = {3,1,7,5,9,19,8,2,5,6,6,8};
uchar *sp;
sp = niu;
a = *sp;
printf("a = *sp 结果:a = %d\n",a) ;
b = *sp + 1;
printf("b = *sp + 1 结果:b = %d\n",b);
c = *sp++;
printf("c = *sp++ 结果:c = %d\n",c) ;
d = *sp;
printf("d = *sp 结果是:d = %d\n",d);
e = *(sp+1);
printf("e = (*sp+1) 结果是:e = %d\n",e);
f = *sp;
printf("f = *sp 结果是:f = %d\n",f);
x = sizeof(niu) ;
printf("x = sizeof(niu) 结果是:x = %d\n",x);
y = sizeof(sp);
printf("y = sizeof(sp) 结果是:y = %d\n",y);
z = sizeof(*sp);
printf("z = sizeof(*sp) 结果是:z = %d\n",z);
g = *(sp+sizeof(*sp)) ;
printf("g = *(sp+sizeof(*sp)) 结果是:g = %d\n",g);
h = *(sp+sizeof(sp)) ;
printf("h = *(sp+sizeof(sp)) 结果是:h = %d\n",h);
return 0;
}
运行结果
#include <stdio.h>
typedef unsigned char uchar;
int main(void)
{
uchar a,b,c,d,x;
uchar niu[]="edu118";
printf("niu的地址是:%p\n",niu);
uchar nsd[6]="edu118";
printf("nsd的地址是:%p\n",nsd);
uchar *sp,*ss;
sp=niu;
printf("sp的地址是: %p\n",sp);
ss=nsd;
printf("ss的地址是: %p\n",ss);
a = *sp;
printf("a = *sp 的结果是: %c\n",a);
b = sp[0];
printf("b = sp[0] 的结果是: %c\n",b);
c = sp[5];
printf("c = sp[5] 的结果是: %c\n",c);
d = *(sp+6);
printf("d = *(sp+6) 的结果是:十进制:%d 字符:%c\n",d,d);
x = *(ss+7);
printf("x = *(ss+7) 的结果是:%d\n",x) ;
return 0;
}
知识还是要用起来,学习还要日积月累
|