I'm having a problem on my dynamic allocation stack...I try many changes, but unsuccessfully....When the program doesn't freeze, it says "Empty Pile"....
I put here a piece of my work, where I think has a problem....If you need more, I post later.....and If you can't understand, ask me, because I'm too lazy to translate....^^
Fix for me guys
DesceAviao() get a element of queue "v" and put in the stack "d"....
Desenfileira() get a element out of the queue....
I can't undestand what do you talk about the Empilha(), can you explain again?????..."Empilha()" get a element and put in the stack...."Topo" is the stack out of the function....When the Empilha finish, the "p" return in the place of "topo".....
I can't undestand....my objetive is put "p" on the place of "topo", because I get "topo" and the internal values of its for the "p", when I put "aviao" in the top and "topo" below....How can I put the "p" in the place of "topo"????
void Empilha(PILHA *&topo, struct REG &elemento) // Note: *& means you have a reference to your pointer
// i.e. the modification of the pointer will also have an effect on the caller
struct NODO *p;
p = (struct NODO * )malloc(sizeof(struct NODO));
p->dado = elemento;
p->proximo = topo;
topo = p; // Note: this will set 'topo' to the newly created node
// no need to return something
return p; // p é o novo topo
int DesceAviao(FILA *v, PILHA *&d) // Note: *& is needed here also to transport the change of 'topo' outside of this function!
By the way: basically, when you pass a (non const) reference like struct REG &elemento to Empilha() means that you can modify elemento and aviao->dado (on line 40) is changed too