2
Error of the function pop
??
void pop(Pilha *pilha){
if(pilha->size == 0){
puts("pilha vazia");
} else {
printf("item removido: %d\n\n", pilha->itens[--pilha->size]);
free(pilha->itens[--pilha->size]);
}
}
Link to Stack.
2
Error of the function pop
??
void pop(Pilha *pilha){
if(pilha->size == 0){
puts("pilha vazia");
} else {
printf("item removido: %d\n\n", pilha->itens[--pilha->size]);
free(pilha->itens[--pilha->size]);
}
}
Link to Stack.
5
You decrease the value of pilha->size
twice. It is right to do it only once.
-3
The stack size is decreasing more than once per loop. Remember that --
really changes the value of the variable.
void pop(Pilha *pilha){
if(pilha->size == 0){
puts("pilha vazia");
} else {
printf("item removido: %d\n\n", pilha->itens[--pilha->size]);
free(pilha->itens[pilha->size]);
}
}
Browser other questions tagged c stack
You are not signed in. Login or sign up in order to post.
Probably this code will give execution problem in the second withdrawal...
– Felipe Avelar