Here is the pop()
function, I have written to pop an element of a stack. So far, I have succeeded in pushing elements into a stack and showing the stack. So, I guess my pop()
function is doing wrong somewhere. Here is my pop function:
void pop(int newstack[], int *newtop, int bound )
{
int item;
if(*newtop<0)
printf("\n CAUTION!!! UNDERFLOW");
else
{
item=newstack[*newtop];
*newtop--;
printf("\n Element popped->%d",item);
}
}
Taking no chance, I am also posting the show()
function:
void show_stack(int newstack[], int *top)
{
int i;
printf("\n");
for(i=0;i<=*top;i++)
printf("%d",newstack[i]);
}
I guess there is no error in the show function.