读书人

printf(quot;%d\nquot;point_t[1]);//为啥异常

发布时间: 2012-03-25 20:55:17 作者: rapoo

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();} 

读书人网 >C语言

热点推荐