c - Evaluate postfix notation -



c - Evaluate postfix notation -

i doing exercise stucked @ lastly step. have evaluate postfix notation using stacks in c. code:

#include<stdio.h> #include<stdlib.h> #define max 100 typedef struct { int info; }tipelement; typedef struct { tipelement magacin [max]; int vrv; }tipmagacin; tipmagacin postfixstack; void inicijalizacija(tipmagacin *mag) { (*mag).vrv = -1; //warehouse empty } int prazen(tipmagacin mag) { return(mag.vrv == -1); //returns true if warehouse empty } int poln(tipmagacin mag) { return(mag.vrv == max-1); //returns true if warehouse total } void push(tipmagacin *mag, tipelement element) { if (poln(*mag)) printf("warehouse full\n"); //if total study error else { (*mag).vrv++; //next position in warehouse (*mag).magacin[(*mag).vrv].info = element.info; //put element } } void pop(tipmagacin *mag, tipelement *element) { if (prazen(*mag)) printf("warehouse empty\n"); //if empty study error else { (*element).info = (*mag).magacin[(*mag).vrv].info; //read lastly element (*mag).vrv--; // delete } } int evaluate(int op1, int op2, char operate) { switch (operate) { case '*': homecoming op2 * op1; case '/': homecoming op2 / op1; case '+': homecoming op2 + op1; case '-': homecoming op2 - op1; default : homecoming 0; } } int evaluatepostfix (char *izraz, int n) { tipmagacin *mag; tipelement element; tipelement go,z; int i=0; int op2; char ch; int value; while (i < n) { element.info = izraz[i]; if(isdigit(element.info)) { push(&postfixstack, element); } else { z=pop(&postfixstack, &go); op2=1; value = evaluate(z,op2,ch); push(mag,value); } i++; } homecoming value; }

my code works fine until here:

else { op1=pop(&postfixstack, &go); op2=pop(&postfixstack, &go); value = evaluate(op1,op2,element.info); push(&postfixstack, value); } i++; } homecoming value; }

the problem is: error: void value not ignored ought force , pop functions void , need set value remove stack int variable calculate them. set doesnt set reason dont know. help ?

c stack postfix-notation

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -