Non-recursive function c does not work
Dear friends,
Here is the C source code :
void travpost(node *root) {
node *p=root, *q=NULL;
stk.top=-1;
do {
while(p!=NULL)) {
push(P);
p=p->left;
}
if(stk.top!=-1) {
p=p->left;
}
if (stk.top!=-1) {
p=pop();
if((p->right!=q)&&(p->right!=NULL)){
push(p);
p=p->right;
}
else {
printf("%d t", p->info);
q=p;
p=NULL;
}
}
while(stk.top!=-1);
}
void push(node * p) {
stk.arr[++stk.top]=p;
}
node* pop(){
return stk.arr[stk.top–];
}
}
[Error] C:Program FilesC-Free 5appdatasamplesnon-recursive.c:1: error: syntax error before '*' token
[Error] C:Program FilesC-Free 5appdatasamplesnon-recursive.c:2: error: 'node' undeclared (first use in this function)
[Error] C:Program FilesC-Free 5appdatasamplesnon-recursive.c:2: error: (Each undeclared identifier is reported only once
[Error] C:Program FilesC-Free 5appdatasamplesnon-recursive.c:2: error: for each function it appears in.)
Â
Please review the source code; if anybody rectifies the errors, please comment immediately. I will be thankful to you.