probleme avec les structures
Salut à tous, voilà j'ai un probleme avec l'initialisation de ma structure;
j'ai crée un header nommé "essai.h":
Code:
1 2 3 4 5 6 7
| typedef struct Identite Identite;
struct Identite {
char nom[20];
char prenom[20];
char sexe[10];
int age;
}; |
et par la suite dans le main()
j'ai ceci:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include "essai.h"
int main ()
{
Identite Candidat;/*création d'une variable de type Identité*/
Candidat.nom= "Quentin";
Candidat.prenom="Cyrille";
Candidat.sexe="Masculin";
Candidat.age=21;
printf("Le candidat s'apelle %s %s\n",Candidat.nom,Candidat.prenom);
printf("Il est de sexe %s et a %d ans\n",Candidat.sexe,Candidat.age);
printf("C'etait un test sur les structures\a");
return 0;
} |
seulement le compilateur me retourne un message d'erreur:
Citation:
7 D:\Cyril\Dev-Cpp\fonction C\test de struct.cpp incompatible types in assignment of `const char[8]' to `char[20]'
je suis bloqué,je ne comprends d'où la constante " const char[8]", j'utilise Dev-C++
:tagcode: