Close Sajet... But your allocation only allocates space for an unsigned integer/pointer, since name is a pointer. You need the sizeof(datas).
Not true notice Sajet wrote
name = (struct datas *)malloc(sizeof *name);
not
name = (struct datas *)malloc(sizeof name);
since *name is a struct of type datas sizeof *name returns the size of the struct name points to. In fact for me
name = malloc(sizeof *name);
is preferable to
name = malloc(sizeof (datas));
because if the type of name is changed (which I admit is notterribly likely) the first form of the malloc still works without alteration where as the second requires a change to the sizeof to work correctly. For any type T using
T *pointer;
pointer = malloc(sizeof *pointer);
is about the most robust way you can write the malloc. NOTE I have removed the casts because they are not necessary (in fact they are dangerous) in C and if you are using C++ you should be using new anyway to ensure and constructors get called.