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 :(

Member Avatar for chanderk

Is there any predefined class "Stack" in c++?? I dont think so.

If its not there, you need to implement your own stack for your algorithm

well here is the main code...

:yawn: and here is probably the original copy (without the copy/paste errors).

Wouldn't it really be better for you to write the program from the ground up (in terms of really learning something) ?

Is there any predefined class "Stack" in c++?? I dont think so.

If its not there, you need to implement your own stack for your algorithm

I'm very stupid in header files... I'm so upset :(

Member Avatar for chanderk

No need to be upset for this.. Better u find, what are the use of other headers you have included in your code. And what happens if you do not include them. Find out where are those files and what si the content of the file.

After finding out answer for these.. think.. what should you have to get / have to get stack functionality in your code..

:yawn: and here is probably the original copy (without the copy/paste errors).

Wouldn't it really be better for you to write the program from the ground up (in terms of really learning something) ?

god damn it's all the same arrrrrggggghhhh...... I'lll make new again

Member Avatar for iamthwee

There is a stack in c++.

It is defined in the header #include <stack>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.