Jump to content
Sign in to follow this  

Erros de Tipos

Recommended Posts


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct sChamada
 char *ident;
 char tipo [1];
 char data [10];
 char hora [5];
} Chamada;

typedef struct sLista
 Chamada tel;
 struct sLista *seg;
} *Lista, nLista;

Chamada criachamada ()
 char nome2 [25];
 char numero2 [15];
 char tipo2 [1];
 char data2 [10];
 char hora2 [5];

 Chamada cham;
 printf ("Introduza um nome: \n");
 fgets (nome2,25, stdin);
 cham.ident= strdup(nome2);
 if (nome2[0]=='\n') 
   printf ("Introduza um número: \n");
   fgets (numero2,15,stdin);
    if (numero2[0]=='\n') 

 printf("Introduza um tipo: E(fectuada); R(ecebida) \n");
 fgets (tipo2,1, stdin);
 cham.tipo = strdup(tipo2);
 printf ("Introduza uma data do tipo dd-mm-aaaa: \n");
 fgets (data2,10, stdin);
 cham.data = strdup(data2);
 printf("Introduza uma hora do tipo hh:ss \n");
 fgets (hora2,5, stdin);
 cham.hora = strdup(hora2);

 return cham;

Lista crialista (Chamada a, Lista b)
 Lista agenda=NULL;
 agenda->tel = a;
 agenda->seg = b;
 return agenda;

void main ()
 Chamada exp;
 Lista des=NULL;
 exp=criachamada ();
 //des=crialista ();

Está a dar erros na função criachamada: "incompatible types when assigning to type ‘char[1]’ from type ‘char *’"

Se me puderem ajudar agradeço

Share this post

Link to post
Share on other sites

Se estás a declarar como array de chars não lhe podes mudar o endereço... não são ponteiros.

Podes utilizar strcpy() em vez de strdup().

“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

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.