memory management - C, set a variable in a structure -
i have problem program written in c. indeed, stops @ line e->identifiant=0;
code :
struct evenement* e=(struct evenement*)(malloc(sizeof(struct evenement))); e->identifiant=0;
with :
struct evenement{ int identifiant; char titre[100]; struct creneau creneau; char lieu[50]; char description[500]; };
have idea ?
i compiled , run this:
#include <stdio.h> #include <stdlib.h> struct evenement{ int identifiant; char titre[100]; char lieu[50]; char description[500]; }; int main() { struct evenement* e=(struct evenement*)(malloc(sizeof(struct evenement))); e->identifiant = 0; printf("%d", e->identifiant); return 0; }
and, there no problem. can tell error?
i deleted struct creneau creneau;
line, beacuse no description of it. can problem?
Comments
Post a Comment