Problem making strings in a malloc-ed struct
I have a struct with the following definition:
The problem is that I want to make a linked list of these nodes, each having its own name. These names are to come from standard input -- that is, they are not static. I can't figure out how to put a string into the "name" field of a dynamically allocated node so that it doesn't disintegrate when the function that it was created within completes execution. I'm pretty sure there's no way to malloc a string. Does anyone have any suggestions? I've been working on this one little problem for over 40 minutes.
char * name;
struct node * next;