I have a struct element and I want to copy the element data (in all fields) to another element.
So if this is the struct
struct Node{
  char* name;
  char type;
  char* path;
};
and this is my copy function :
struct Node Node_cp(struct Node member)
{
  struct Node NewMember;
  NewMember=malloc(sizeof(struct Node))
  //**Here i get error : Assigning to struct Node from incompatible type void* (why ?)**
  NewMember.name=member.name;
  NewMember.type=member.type;
  NewMember.path=member.path;
  return NewMember;
}
- My Questions :
- why do i get this error on the malloc ?
- is this the right way to do it ? I'm going
- should i use malloc on newMember.path=malloc(sizeof(member.path)) and in all other fields as well ? - editing to explain why my question is different from using typedef in struct because the system think this is a duplicate question : Well as i understand in C this are totally different questions. I asked about copying an element and not on typedef :< 
Thanks
 
     
    