I would like to understand how pop
works in stacks.
I just put the part that I did not understand, I know that in the pop()
function there is also the empty check, but I only put the part that I did not understand.
It turns out that this function that my teacher passed p
points to n
and this will only overwrite when push()
is used and not delete the value. Is that correct?
define MAX = 50;
struct Pilha {
int n;
float vet[MAX];
}
float pop(Pilha *p) {
float v;
v = p->vet[p->n];
p->n--;
return v;
}