Erro de compilação

0 respostas
paloma

O programa roda mas o resultado ñ é o esperado, acho que o problema tá no loop mas ñ consigo identificar, alguém pode me dar uma ajuda? :roll:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

typedef struct edificio{
       char nome[51];
       int hora;
       int min;
       struct edificio *prox;
}edf;

//VARIÁVEIS GLOBAIS
char nome[51];
int hora, min;
edf *lista;

//FUNÇÃO AUXILIAR
void cadastro ()
{
         printf ("Entre com o nome: ");
         fgets (nome,51,stdin);
         printf ("\n");

         printf ("Entte com a hora: ");
         scanf ("%d",&hora);
      
         printf ("Entre com os minutos: ");
         scanf ("%d", &min);
         printf ("\n");
}

//FUNÇÃO INCLUIR
void incluir ()
{
     edf *ptr;

     cadastro ();

     ptr = (edf*)calloc(1,sizeof(edf));
     strcpy(ptr -> nome, nome);
     ptr -> hora = hora;
     ptr -> min = min;
     ptr -> prox= NULL;

     if (lista == NULL)
     {
        lista = ptr;
     }
     else
     {
         ptr -> prox = lista;
         lista = ptr;
     }
}

//FUNÇÃO CRIA LISTA VAZIA
edf* vazia(void)
{
      return NULL;
}

//FUNÇÃO EXCLUIR
void excluir()
{
     edf *aux1;
     edf *aux2;

     cadastro();

     aux2 = NULL;
     aux1 = lista;

     while ((aux1!= NULL) && (aux1 -> nome != nome) || (aux1 -> hora != 
hora) || (aux1 -> min != min))
     {
           aux2 = aux1;
           aux1 = aux1 -> prox;
     }

     if (aux2 == NULL)
     {
              lista = aux1 -> prox;
     }

     else
     {
         aux2 -> prox = aux1 -> prox;
     }

     free (aux1);

     printf ("O nome foi excluido \n");
}

//FUNÇÃO LISTAR
void listar()
{
     edf *aux;

     aux = lista;

     while (aux != NULL)
     
     {    
           printf ("Nome: %s", aux -> nome);
           printf ("Horas: %d", aux -> hora);
           printf ("Minutos: %d", aux -> min);

           aux = aux -> prox;
      }
}

//FUNÇÃO PRINCIPAL
int main()
{
     char op;

     do{
          printf ("(I)ncluir\n");
          printf ("(E)xcluir\n");
          printf ("(L)istar\n");
          printf ("(S)air\n");
          printf ("\n");
          printf("Digite a opcao: ");
          
          op = toupper (getchar());

          switch (op)
          {
                 case 'I': incluir ();
                 break;

                 case 'E': excluir ();
                 break;

                 case 'L': listar ();
                 break;
           }

          system ("PAUSE");

          }while(op != 'S');

    return (0);
}
Criado 6 de abril de 2006
Respostas 0
Participantes 1