function problem

Aug 16, 2013 at 9:23am
void postfix(char *infix,char *postr)
{
int position,und;
int outpos=0;
char topsymb='+';
char symb;
struct stack opstk;
opstk.top=-1;
for(position=0; (symb=infix[position])!='\0'; position++)
if(isoperand(symb))
postr[outpos++]=symb;
else
{
popandtest(&opstk,&topsymb,&und);
while(!und &&prcd(topsymb,symb))
{
postr[outpos++]=topsymb;
popandtest(&opstk,&topsymb,&und);
}
if(!und)
push(&opstk,topsymb);
if(und||(symb!=')'))
push(&opstk,symb);
else
topsymb=pop(&opstk);
}
while(!empty(&opstk))
postr[outpos++]=pop(&opstk);
postr[outpos]='\0';
return;
}

can yu explain me what this popandtest() function is doing and what is the use of und .
getting problem because of these in the code.
please help

Aug 16, 2013 at 11:52am
can yu explain me what this popandtest() function is doing and what is the use of und

Without seeing the code of popandtest it is impossible to know. und appears to be set by popandtest to some value, i.e. it is an output/return value of the function. Possibly boolean content, although type is int.
Aug 16, 2013 at 7:33pm
topsymb=opstk.pop(und);
return topsymb

is the definition for popandtest()
Aug 17, 2013 at 5:15am
Please help
Aug 17, 2013 at 8:16am
just guessing: und might be the size of the stack after an element has been popped

Then the name 'popandtest' would mean 'pop element and test size'
Last edited on Aug 17, 2013 at 8:19am
Topic archived. No new replies allowed.