Originally posted by KabalProg
What you have to do is to reserve some space for the string with malloc and then copy the string char by char:

Ask for memory for the string:

temp->name=(char*) malloc(strlen(nm)+1);

Copy the string:

strcpy(temp->name, nm);

And that's it

Hope this helped

Kabalprog
Actually, that's not it. For every malloc() you have in your
program, there should be a corresponding free(). If you don't
know this already, then look up malloc() in your compiler's
documentation.

Since you gave a .c file, I assume you're writing a C program and
asking questions about it here [in a C++ forum]. That's fine. I
just wanted to make the point that if you're using C++, it is
recommended that you use new and delete instead of malloc()
and free(). For YOUR particular case it's probably not an issue,
but it's for those people who read this post as a result of a google
search four years from now

--Paul