I feel that all or almost all of the stack arrays needs a stack header... well this is the project target... I need to input a postfix algorithm an check whether it validates or not... I'm not very familliar with headers could some one suggest it for me or make a header code for me. well here is the main code...
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "????.H"
int main()
{
Stack myStack;
char <strong class="highlight">postfix</strong>[20],op[3],num1,num2;
int i,j = 0;
CreateStack(&myStack);
printf("Enter the <strong class="highlight">postfix</strong> expression\n");
scanf("%s",postfix);
for(i = 0; <strong class="highlight">postfix</strong>[i] != '\0'; i++)
{
if(<strong class="highlight">postfix</strong>[i] != '+' && <strong class="highlight">postfix</strong>[i] != '-' && <strong class="highlight">postfix</strong>[i] != '/' && <strong class="highlight">postfix</strong>[i] != '*')
{
Push(<strong class="highlight">postfix</strong>[i],&myStack);
}
else
{
if(StackSize(&myStack) >= 2)
Pop(&num2,&myStack);
else
{
printf("Invalid <strong class="highlight">postfix</strong> expression\n");
ClearStack(&myStack);
return 0;
}
}
}
ClearStack(&myStack);
for(i = 0; <strong class="highlight">postfix</strong>[i] != '\0'; i++)
{
if(<strong class="highlight">postfix</strong>[i] != '+' && <strong class="highlight">postfix</strong>[i] != '-' && <strong class="highlight">postfix</strong>[i] != '/' && <strong class="highlight">postfix</strong>[i] != '*')
{
Push(<strong class="highlight">postfix</strong>[i],&myStack);
}
else if(<strong class="highlight">postfix</strong>[i] == '+' || <strong class="highlight">postfix</strong>[i] == '-' || <strong class="highlight">postfix</strong>[i] == '/' || <strong class="highlight">postfix</strong>[i] == '*')
{
if(<strong class="highlight">postfix</strong>[i] == '+')
strcpy(op,"AD");
else if(<strong class="highlight">postfix</strong>[i] == '-')
strcpy(op,"SB");
else if(<strong class="highlight">postfix</strong>[i] == '*')
strcpy(op,"ML");
else if(<strong class="highlight">postfix</strong>[i] == '/')
strcpy(op,"DV");
Pop(&num2,&myStack);
Pop(&num1,&myStack);
if(num1 < 97)
printf("LD TEMP%d\n",num1);
else
printf("LD %c\n",num1);
if(num2 < 97)
{
printf("%s TEMP%d\n",op,j);
j++;
Push(j,&myStack);
printf("ST TEMP%d\n",j);
}
else
{
printf("%s %c\n",op,num2);
j++;
Push(j,&myStack);
printf("ST TEMP%d\n",j);
}
}
}
return 0;
}
you see that there's
#include "???.H" in line 4
I do not know what to do there. pls help :(