- #include <stdio.h>
- int main()
- {
- char a[]={'a','b','c','\0'};
- char *h=a;
- printf("h[0]=%c\th[0+1]=%c\th[0+2]=%c\th[3]=%c\th[4]=%c\n",h[0],h[0+1],h[0+2],h[3],h[4]);
- printf("*h=%c\t*(h+1)=%c\t*(h+2)=%c\t*(h+3)=%c\t*(h+4)=%c\n",*h,*(h+1),*(h+2),*(h+3),*(h+4));
- char *j=&a[2];
- printf("j[0-3]=%c\tj[0-2]=%c\tj[0-1]=%c\tj[0]=%c\tj[0+1]=%c\n",j[0-3],j[0-2],j[0-1],j[0],j[0+1]);
- printf("*(j-2)=%c\t*(j-1)=%c\t*(j)=%c\t*(j+1)=%c\t*(j+2)=%c\n",*(j-2),*(j-1),*(j),*(j+1),*(j+2));
- int c=1,b=2;
- int *i=&c;
- printf("*i=%d\n",*i);
- i=i-1;
- printf("*i=%d\n",*i);
- return 0;
- }
复制代码
|
|