温习C语言(1):指针与地址

#include<stdio.h>
#include<stddef.h>

int main(int argc,char **argv) 
{ 	
	char c;
	char *p = &c;
	printf("len of char is %d\n",sizeof *p);
	
	int x = 1, y = 2, z[10]={8,22,33};
	int *ip = &x;
	printf("x,y is %d,%d\n",x,y);
	
	y= *ip;
	printf("x,y is %d,%d\n",x,y);
	
	*ip = 0;
	printf("x,y is %d,%d\n",x,y);
	
	ip = z;
	x = *ip;
	printf("x,y is %d,%d\n",x,y);
	
	*ip = *ip + 10;
	y = *ip + 1;
	printf("x,y,*ip is %d,%d,%d\n",x,y,*ip); //8,19,18
	
	++*ip;
	x = *ip;
	printf("x,y,*ip is %d,%d,%d\n",x,y,*ip); //19,19,19
	
	(*ip)++;
	printf("x,y,*ip is %d,%d,%d\n",x,y,*ip); //19,19,20
	
	*ip++;
	printf("x,y,*ip is %d,%d,%d\n",x,y,*ip); //19,19,22	
	
	return 0;
}

  

posted @ 2012-11-01 23:46  代码示例  阅读(833)  评论(0编辑  收藏  举报