正在加载图片...
例8-1利用指针模拟寻找保险箱 密码的过程 If I know the name of the variable i can get i it's value by name: 911 If know the address of the variable 获取密码的两种方法 is: 12ff7C, then I also can get it's value by int main(void) address: 911 int key=911;/*变量key用于存放密码值911*/ int*p addr=NULL;/*变量 p addr是整型指针变量*/ p_addr =&key /将key的地址赋给 p addr* /通过变量key输出密码值* printf(" the key is: %dn", key) /通过变量名key输出密码值 printf("If I know the name of the variable, I can get it's value by name %dIn", key) /通过变量key的地址来输出密码值 printf( if I know the address of the variable is: %x, then I also can get it's value by address: %dn",p addr, *p_addr); return 0:例8-1 利用指针模拟寻找保险箱 密码的过程 获取密码的两种方法 int main(void) { int key = 911; /* 变量key用于存放密码值911 */ int *p_addr = NULL; /* 变量p_addr是整型指针变量 */ p_addr = &key; /* 将key的地址赋给p_addr*/ /* 通过变量key输出密码值*/ printf("The key is: %d\n", key); /* 通过变量名key输出密码值*/ printf("If I know the name of the variable, I can get it’s value by name: %d\n ", key); /* 通过变量key的地址来输出密码值*/ printf("If I know the address of the variable is: %x, then I also can get it’s value by address: %d\n",p_addr, *p_addr); return 0; } If I know the name of the variable, I can get it’s value by name: 911 If I know the address of the variable is:12ff7c, then I also can get it’s value by address: 911
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有