Well basicly the problem is that i have to call the function push while the char that is asked for is not '0' then i have to send the modified "*top" and "*temp" into the function POP so that i can show the values and do the deleting of the charaters that where introduced f3
I think i didnt explained myself verywell i hope you can help me, this is the code i got so far
#include <iostream>
#include <conio.h>
using namespace std;
struct Stack
{
char letra;
Stack *next;
};
void push(char n, Stack *top, Stack *temp)
{
temp=new(Stack);
temp->letra=n;
temp->next=top;
top=temp;// i need to return this values to the main
}
void pop(Stack *top, Stack *temp)//this function should receive the values of top and temp from function push()
{
int x1;
temp=top;
x1=temp->letra;
cout<<x1;
top=top->next;
delete temp;
}
int main()
{
Stack *start=NULL, *temp=NULL;
char x;
do
{
cin>>x;
push(x,start,temp);//i think this function is working
}
while(x!='0');
while(top!=NULL)
{
pop(start,temp);//my problem is here f3
}
getch();
}
The assignment says that we cant use global declarations for the Stack *start or any Stack structure
which would make this program alot easier f3.
This is my first time using stacks so i know i messed up really bad.
Hope you can help me
Thank you