Dereferencing pointer to incomplete type

0

How can I solve the "dereferencing pointer to incomplete type" problem? I can not find where the error is.

Below are the statements.

typedef struct{
  int dia,mes,ano;
}data;

typedef struct {
  char matricula[10];
  data _matricula;
  data _conclusao;
  char curso[25];
  char universidade[50];

}universitario;

typedef struct {
  data _deposito;
  float renda;  
}poupanca;

typedef struct {

  float salario;
  char orgao_trabalha[50];
  char cargo[12];
  data _contratacao;
}salario;


typedef struct{ 

}corrente;

typedef struct {

  char nome [25];
  char sobrenome[25];
  char endereco[50];
  char email[25];
  char telefone[12];
  char CPF[12];
  int ID; 
  union conta_tipo{
    universitario u;    
    poupanca p;
    salario s;
    corrente c;
  };
}cadastro;


struct cadastro c1;
void preencher_cadastro (struct cadastro *p,int tipo_conta){

  printf ("Insira o nome do cliente a ser cadastrado:  ");
  setbuf (stdin,NULL);
  fgets (p->nome,25,stdin);[![inserir a descrição da imagem aqui][1]][1]
  printf("Insira o sobrenome do cliente a ser cadastrado:  ");
  setbuf (stdin,NULL);
  fgets (p->sobrenome,25,stdin);
  setbuf (stdin,NULL);

According to IDE, the error is in all fgets.

    
asked by anonymous 14.06.2018 / 04:24

1 answer

2

When using the type, you are using "struct register", when you should only use "register", since the type register is already properly defined as struct.

If the struct is defined this way:

struct cadastro { ... membros ... }

Then it would be necessary to use 'struct register' with each use of the structure. But the typedef form is much more usual because it avoids having to repeat the keyword.

In C ++ I think the rule is a bit different: declaring 'struct register' has the same practical effect as using typedef, and just use the type name (without struct) in the code.

    
14.06.2018 / 06:55