
		dsquare
		
		(usa OpenSuSE)
		
		Enviado em 26/05/2009 - 09:27h 
		Olá,chamo-me Adilson,vivo em Cabo Verde e estudo 1ºano de engenharia sistemas e informática.Estou a desenvolver um mini-proj que apresenta o seguinte menu:
*inserir estudante
*remover estudante
*listar estudante
*actualisar estudante
*sair.
Feito atravéz duma lista circular duplamente encadeada. Estou com algumas duvidas ainda, e não consigo passar as funções correctamente para a função "main".Agradecia mt que dessem uma olhadela nos ERROS e se pudessem corrigi-los explicando:
#include <stdio.h> 
#include <string.h>
#include <stdlib.h>
#define Null
#define pesquisar_igual
#define Inserir '1'
#define Remover '2'
#define Listar '3'
#define Actualisar '4'
#define Sair '5'
char*main_menu(){
   "1. Inserir Estudante";
   "2. Remover Estudante";
   "3. Listar Estudante";
   "4. Actualisar Estudante";
   "5. Sair";
 }      
        
FILE *fp
 fp=fopen ("DATA Txt","wb");
 void inic(); 
  if(fp==Null)
   return;
    
typedef struct Estudante{
   int BI, Telefone, Ano_curso; 
   char Nome[100], Endereco[100], Curso[100];
   struct estudante *ant, *prox;
 }Estudante;
void inserir(Estudante **ptr,int v){
    
   Estudante *novo=(Estudante*) malloc(sizeof (Estudante));
       novo->BI=v;
       novo->Telefone=v;
       novo->Ano_curso=v;
       novo->prox=ptr;   
       novo->ant=ptr;    
        
        if(ptr!=NULL){
          novo->BI=v; 
          novo->Telefone=v;
          novo->Ano_curso=v;
          novo->prox=v;
          novo->ant=v; 
          return novo; 
         } 
 }   
     
void remover(Estudante **lst, int BI){
    
   Estudante *aux;
   if(*lst == NULL){
      puts("\n\tNAO HA NENHUM ELEMENTO PARA SER REMOVIDO!!! \n");
         return;
     }else{     
         printf("\n\tRemover Estudante? \n\tDigite o Respectivo Numero BI: ");
         getchar();
         scanf("%d\n",&BI);
         aux =pesquisar_igual(lst),BI;
         if(aux == NULL){    
            printf("\n\n\tESTE ELEMENTO NAO EXISTE!!!\n");
              return;
          }else if(aux->ant == aux){
              *lst=NULL;
              free(aux);
              printf("\n\n\tELEMENTO REMOVIDO COM SUCESSO!!!\n");
                return;
            }else if(aux == *lst){
                *lst = (*lst)->prox;
                (*lst)->ant = aux->ant;
                aux->ant =*lst;    
                aux->prox=*lst;    
                free(aux);         
                printf("\n\n\tELEMENTO REMOVIDO COM SUCESSO!!!\n");
                 return;
              }else{    
                  aux->ant = aux->prox;
                  aux->prox = aux->ant;
                  free(aux);     
                  printf("\n\n\tELEMENTO REMOVIDO COM SUCESSO!!!\n");
                   return;
                }
       }
 }
void ler(Estudante *x){
     printf("Digite o Numero do BI: "); scanf("%d\n",&x->BI);
     printf("Digite o Nome: "); gets(x->Nome);
     printf("Digite o Endereco: "); gets(x->Endereco);
     printf("Digite o Numero de Telefone: "); scanf("%d\n",&x->Telefone);
     printf("Digite o Curso: "); gets(x->Curso);
     printf("Digite o Ano de Curso: "); scanf("%d\n",&x->Ano_curso);
     fflush(stdin);
 }
           
void mostrar(struct Estudante y){
     printf("BI: %d\n", y.BI);
     printf("Nome: %s\n", y.Nome);
     printf("Endereco: %s\n", y.Endereco);
     printf("Telefone: %d\n", y.Telefone);
     printf("Curso: %s\n", y.Curso);
     printf("Ano de Curso: %d\n", y.Ano_curso);
 }                    
 
void listar(Estudante *lst){
     
     if(lst==0){
        printf("\n\tNao Existe Nenhum Estudante\n");
      }   
     else{
         printf("%s  %d\n", lst->Nome,lst->BI);
         listar(lst->prox);
      }
 } 
main(){
    char s[50];
    char opcao,z;
    FILE *fp;
    inic();  
    fp=fopen("DATA Txt","rb");
     if(fp==0){
         printf("Imposivel abrir o ficheiro %s\n",s);
         exit(1);
      }
    inic();
     Ler(&z);
    while((opcao=Menu(main))!=5){
       switch(opcao){
           struct Estudante z;
          case 1 : Inserir;   
            Inserir(&z);      
            break;
          case 2 : Remover;
            Remover(&z);   
            break;
          case 3 : Listar(;
            Listar(z);
            break;
          case 4 : Actualisar(&z); break;
        }
      }  
    fclose(fp);
 }
  
Meu e-mail: dsquare.ac@hotmail.com