liyong
unread,May 5, 2008, 10:06:36 PM5/5/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to 姚博士的论坛-教学
以下是我编的程序的一部分:
struct STNode //树节点
{
string data;
struct STNode *parent,*firstchild,*nextsibling;
};
struct Stack //栈结构
{
STNode *base;
STNode *top;
int stacksize;
};
int Initstack(Stack &s) //初始化栈
{
s.base=(STNode *)malloc(STACK_INIT_SIZE *sizeof(STNode));
if(!s.base) exit(OVERFLOW);
s.top=s.base;
s.stacksize=STACK_INIT_SIZE;
return OK;
}
int Push(Stack &s,STNode e) //压栈
{
/* if(s.top-s.base>=s.stacksize)
{
s.base=(STNode *)realloc(s.base,(s.stacksize
+STACKINCREMENT)*sizeof(STNode));
if(!s.base) exit(OVERFLOW);
s.top=s.base+s.stacksize;
s.stacksize=s.stacksize+STACKINCREMENT;
}*/
s.top->parent=e.parent;
s.top->firstchild=e.firstchild;
s.top->nextsibling=e.nextsibling;
// s.top->data=e.data;
s.top++;
return OK;
}
为什么不能给s.top->data赋值呀?
给它赋值就出现"Unhandled exception in SuffixTrees.exe:0xC0000005:Access
Violation."这种错误。