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

一个关于指针的有关问题

2012-03-24 
一个关于指针的问题.typedefstructobject_element{inttypeintidchar*ptr}Object_elementObject_elemen

一个关于指针的问题.
typedef   struct   object_element
          {
int     type;  
int     id;  
char   *ptr;
          }   Object_element;

Object_element             subject,   *refs;

element_info(p_draw,   &subject,   PRO_IDENTIFY,   -1,   &refs);

printf( "ptr   =   %d ",   refs[0].type);
printf( "ptr   =   %d ",   refs[0].id);

if   (refs[0].ptr   !=   0)
{
printf( "ptr   =   %s ",   refs[0].ptr);
}

====================

element_info是个API函数
程序运行到printf( "ptr   =   %s ",   refs[0].ptr);
的时候就出现内存问题
请问为什么呢




[解决办法]
refs[0].ptr 没有被赋给一个有效的地址

热点排行