Non-recursive function c does not work

Asked By 0 points N/A Posted on -
qa-featured

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.

SHARE
Best Answer by JamesAlexander
Answered By 0 points N/A #118734

Non-recursive function c does not work

qa-featured

Hi!

You have to write the prototype of the function that is defined at the end of your program. Hope these error vanished…

Best Answer
Best Answer
Answered By 0 points N/A #118735

Non-recursive function c does not work

qa-featured

Hi James,

  • Have you provided the whole source code? I do not see the definition of the node structure.
  • As per the error, it says that node is not declared before and you are trying to use it. First define the node structure and include the corresponding header file.
  • Please provide complete source code to help you better.

Related Questions