1) learn to properly format your code to make it easier to read and understand.
2) The for loop on line 80 is not formed correcly
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#pragma warning(disable: 4996)
#define max 10
typedef int TipoChave;
typedef struct {
char texto;
} TipoItem;
typedef struct Celula_str *Apontador;
typedef struct Celula_str {
TipoItem Item;
Apontador Prox;
} Celula;
typedef struct {
Apontador Fundo, Topo;
int Tamanho;
} TipoPilha;
void FPVazia(TipoPilha *Pilha)
{
Pilha->Topo = (Apontador) malloc(sizeof(Celula));
Pilha->Fundo = Pilha->Topo;
Pilha->Topo->Prox = NULL;
Pilha->Tamanho = 0;
} /* FPVazia */
int Vazia(TipoPilha Pilha)
{
return (Pilha.Topo == Pilha.Fundo);
} /* Vazia */
void Empilha(TipoItem x, TipoPilha *Pilha)
{
Apontador Aux;
Aux = (Apontador) malloc(sizeof(Celula));
Pilha->Topo->Item= x;
Aux->Prox = Pilha->Topo;
Pilha->Topo = Aux;
Pilha->Tamanho++;
} /* Empilha */
void Desempilha(TipoPilha *Pilha, TipoItem *Item)
{
Apontador q;
if (Vazia(*Pilha))
{ printf(" Erro lista vazia\n");
return;
}
q = Pilha->Topo;
Pilha->Topo = q->Prox;
*Item = q->Item;
free(q);
Pilha->Tamanho--;
} /* Desempilha */
int Tamanho(TipoPilha Pilha)
{
return (Pilha.Tamanho);
} /* Tamanho */
int main()
{
TipoPilha pilha;
TipoItem item;
// Apontador p;
FPVazia(&pilha);
printf(" digite um texto");
int i=0;
char palavra[30];
fgets(palavra, sizeof(palavra), stdin);
while (palavra[i]!= '0')
{
for(i=0; palavra[i]!=' ' && palavra[i]!='0';i++)
{
item.texto=palavra[i];
Empilha(item, &pilha);}}
while(!Vazia(pilha))
{
printf(" %c \n", item.texto);
Desempilha(&pilha,&item);
if(palavra[i]!='0')
{
i++;
}
}
getch();
} Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343