mateus8 Posted June 13, 2012 at 06:39 PM Report Share #462545 Posted June 13, 2012 at 06:39 PM Boas tenho um projecto para fazer e tou com uns problemas a introduzir um campo nas estruturas. As estruturas em questão são: typedef struct Turno { int num_turno; char sala[15]; char docente[NUM_NOMES]; int capacidade; int num_alunos_inscritos; int hora; int minuto; int duracao; char dia_sem[10]; }*TURNO; typedef struct Disciplina { int codigo; char nome; int num_alunos; TURNO pT; TURNO pTP; TURNO pPL; struct Disciplina *seg; }*DISCIPLINA; typedef struct InsDisc { DISCIPLINA pt_dis; struct InsDisc *seg; }*INSDISC; typedef struct InscTurno { int codigo; int tipo; int numero; //numero do turno struct InscTurno *seg, *ant; }*INSCTURNO; typedef struct Aluno { int numero; char nome[NUM_NOMES]; INSDISC ptDISC; INSCTURNO ptTUR; }*ALUNO; typedef struct No { ALUNO inf; struct No *esq, *dir; }*NO; typedef struct Arvore { int nelementos; NO raiz; }*ARVORE; typedef struct Lista_Turno { TURNO inf; struct Lista_Turno *seg; }*LISTA_TURNO; typedef struct Elemento { DISCIPLINA inf; struct Elemento *seg; }*ELEMENTO; E a funçao que possovelmente esta mal para guardar a inscriçao numa disciplina é: void ler_elemento(ELEMENTO E) { E=Criar_Elemento(); inicializar_elemento(E); printf("\n Codigo da disciplina: "); scanf("%d", E->inf->codigo); } Link to comment Share on other sites More sharing options...
Rui Carlos Posted June 13, 2012 at 08:02 PM Report Share #462560 Posted June 13, 2012 at 08:02 PM Dava jeito dar mais detalhes sobre o problema que estás a ter, em particular se está a dar algum erro. Experimenta fazer scanf("%d", &(E->inf->codigo)); Num scanf precisas de indicar o endereço de memória para guardar o valor, e não o próprio valor. Rui Carlos Gonçalves Link to comment Share on other sites More sharing options...
mateus8 Posted June 13, 2012 at 09:12 PM Author Report Share #462569 Posted June 13, 2012 at 09:12 PM Crasha... vou experimentar com o endereço... e ja digo algo Link to comment Share on other sites More sharing options...
mateus8 Posted June 13, 2012 at 09:27 PM Author Report Share #462573 Posted June 13, 2012 at 09:27 PM essa funçao ja nao crasha era mesmo do endereço,foi um fail xD Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now