#include <stdio.h>
#include <stdlib.h>
#include "point_memory.h"
void lookup_point(void)
{
int a;
int b;
int *a_point;
int *b_point;
char *sa;
char *sb;
a = b;
//b=99;
//b_point = (int*)malloc(sizeof(int));//程序运行时,在堆上开辟一个空间,并把这个空间的地址附给b_point变量。
a_point = &b;//程序在编译阶段,把变量b的地址附给a_point变量。
b_point = a_point;//把变量a_point的值即所指向的地址附给变量b_point;
//a_point = b_point;//把变量b_point的值即所指向的地址附给变量a_point;
*a_point = 10;//操纵变量a_point所指向的地址所存储的值,在这条语句之前一定先要确定变量a_point已经有值,也就是要有指向的地址,否则会抱段错误(linux);
//printf("a=%d/n",a);
printf("a=%d/t&a=%x/t&b=%x/tb=%d/n",a,&a,&b,b);
printf("*a_point=%d/ta_point=%x/t&a_point=%x/n",*a_point,a_point,&a_point);
printf("*b_point=%d/tb_point=%x/t&b_point=%x/n",*b_point,b_point,&b_point);
*a_point = 12;
b=13;
printf("*a_point=%d/ta_point=%x/t&a_point=%x/n",*a_point,a_point,&a_point);
printf("*b_point=%d/tb_point=%x/t&b_point=%x/n",*b_point,b_point,&b_point);
//printf("b=%d/t&a=%x/t&b=%x/n",b,&a,&b);
sb="99";
/*这句相当于把字符串"99"的首地址传给字符变量sb,而字符串"99"的首地址在编译的时候就由内存分配了。这样sb的值就为"99"的首地址。
不过不要期望*sb来操纵变量所指的地址所存储的值,因为""中的字符串,系统中自动把他当作常量看待,任何方式修改99的值就会报错 */
b_point = (int*)malloc(sizeof(int));
sa =(char *)0x872e48; ;//(char*)malloc(20);
*sa = "ssss";
printf("___________sb=%s/tsb(the point direct adrress)=%x/t&/"99/"=%x/n",sb,sb,"99");
printf("___________sa=%s/nsa(the point direct adrress)=%x/t&/"ssss/"=%x/n",sa,sa,"ssss");
//printf("a=%d/t&a=%x/t&b=%x/n",a,&a,&b);
//printf("*a_point=%d/ta_point=%x/t&a_point=%x/n",*a_point,a_point,&a_point);
// printf("*b_point=%d/tb_point=%x/t&b_point=%x/n",*a_point,b_point,&b_point);
//*a_point = 12;
//b=13;
//printf("*a_point=%d/ta_point=%x/t&a_point=%x/n",*a_point,a_point,&a_point);
// printf("*b_point=%d/tb_point=%x/t&b_point=%x/n",*a_point,b_point,&b_point);
}