日期:2014-05-16  浏览次数:20677 次

段错误 求解惑
typedef struct type
{
int offest;
}TypeObj,*TypeHandle;

TypeHandle x;

x->offest = x->offest + 1;  这句话段错误,啥原因啊
------解决方案--------------------
引用:
typedef struct type
{
int offest;
}TypeObj,*TypeHandle;

TypeHandle x;

x->offest = x->offest + 1;  这句话段错误,啥原因啊

你只是定义了一个指针,并没有给指针初始化,就使用了,自然出现段错误。
实际使用
TypeObj obj;
TypeHandle x = &obj;
x->offset=x->offset+1
这样才行