首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

printf("%d\n"point_t[1]);//为啥异常?

2012-03-25 
printf(%d\n,*point_t[1])//为啥错误?!#include stdio.hvoid test(){int* point[2]int temp_o 10

printf("%d\n",*point_t[1]);//为啥错误?!
#include <stdio.h>

void test()
{
  int* point[2];
  int temp_o = 10;
  int temp_t = 20;
  point[0] = &temp_o;
  point[1] = &temp_t;
  int* point_t = *point;
  printf("%d\n",*point_t[1]);//为啥错误?!
}

int main()
{
  test();
}


[解决办法]
知道为啥错不?
 

C/C++ code
#include <stdio.h>void test(){  int* point[2];  int temp_o = 10;  int temp_t = 20;  point[0] = &temp_o;  point[1] = &temp_t;  int* point_t = *point;printf("%d\n",point_t[-1]);//想访问temp_t应该这样,注意栈结构                                                   //但这样访问还是很危险,因为temp_o旁边有时候不一定就是temp_t}int main(){  test();} 

热点排行