pabkil Posted April 30, 2012 at 03:01 AM Report #452180 Posted April 30, 2012 at 03:01 AM Inicialmente bom dia! Bem meu problema é o seguinte, tenho de criar uma lista encadeada com descritor. Já foram definidos nomes de funções e parâmetros. Na função init(), que inicia meu descritor, não consigo alocar memória para ele, como resposta, tenho que o tipo está incompleto. lde.h struct nodo{ int elemento; struct nodo *ant, *prox; }; struct desc_lista{ int tamanho; struct nodo *inicio,*fim; }; struct desc_lista * init(); //Aloca, inicializa e retorna um ponteiro para um descritor de lista; lde.c struct desc_lista *init(){ struct desc_lista *list; list = malloc(sizeof(struct desc_lista)); if(list == NULL){ printf("Erro ao alocar memória"); exit(1); } list->inicio = NULL; list->fim = NULL; list->tamanho = 0; return list; } Desde já agradeço pela ajuda!
KTachyon Posted April 30, 2012 at 08:19 AM Report #452185 Posted April 30, 2012 at 08:19 AM Não estou a ver nenhum problema. O teu código executa sem problemas. Podes ser mais específico no erro que estás a obter? “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.” -- Tony Hoare
pmg Posted April 30, 2012 at 08:39 AM Report #452191 Posted April 30, 2012 at 08:39 AM Faz o include do header no ficheiro de código lde.c #include "lde.h" /* ... */ What have you tried? Não respondo a dúvidas por PM A minha bola de cristal está para compor; deve ficar pronta para a semana. Torna os teus tópicos mais atractivos e legíveis usando a tag CODE para colorir o código!
pabkil Posted May 2, 2012 at 06:27 AM Author Report #452596 Posted May 2, 2012 at 06:27 AM Agradeço pelas respostas. Descobri meu problema, ao invés de ifndef estava colocando ifdef. Falta de atenção RULEZ... ?
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