3
I created a person-like structure and I intend to use it in a chained list, but the following errors appear:
'No has no Member named 'data', 'No' has no Member named 'Prox' and unknow type name 'p'.
The program didn’t even run, someone can help me?
The file . h is as follows:
#ifndef Pessoa
#define Pessoa
typedef struct pessoa{
char nome[25];
char sobrenome[25];
int registro;
}Pessoa;
typedef struct no{
Pessoa dados;
struct no *prox;
}No;
typedef struct lista{
No *cabeca;
No *cauda;
int tamanho;
}Lista;
No* criaNo(Pessoa p);
Lista* criaLista();
void inserir(Lista *l, Pessoa p, int posicao);
void remover(Lista* l, int registro); //pesquisa registro e remove a pessoa
void imprimeLista(Lista* l);
void destruirLista(Lista* l);
#endif
The file . c is as follows:
#include <stdio.h>
#include <stdlib.h>
#include "Pessoa.h"
No* criaNo(Pessoa p)
{
No* n;
n=(No*)malloc(sizeof(No));
n->dados = p;
n->prox = NULL;
return n;
}
Lista* criaLista()
{
Lista* l = (Lista*)malloc(sizeof(Lista));
l->cabeca = NULL;
l->cauda = NULL;
l->tamanho = 0;
return l;
}
void inserir(Lista *l, Pessoa p, int posicao);
{
//já está pronta, porém não achei necessário colocá-la
}
void remover(Lista* l, int registro)
{
//já está pronta, porém não achei necessário colocá-la
}
void imprimeLista(Lista* l)
{
//já está pronta, porém não achei necessário colocá-la
}
void destruirLista(Lista *l)
{
//já está pronta, porém não achei necessário colocá-la
}
You saw this
;left in the.c?void inserir(Lista *l, Pessoa p, int posicao);. Was it only when you passed here? Does the program compile? What do you call to test? It only calls theCriaLista()? And theCriaNo()And called too? In which lines do errors occur?– Maniero
Check if they include the right . h file. It is called "Person. h" in capital letters?
– Jorge B.