I'm having a problem assigning a value to a pointer in one of my structs
This is the struct definition
Here is the code using it:
typedef struct student *student_ptr;
typedef struct node *node_ptr;
struct student students;
where students is an array of student structs inside the node.
node->students[n].name = &name;
The problem is that assigning name to node->students[n].name works fine, but when I call the function again to do the same thing to another student in the students array, both students have the exact same name.
I have tried to scanf directly into node->students[n].name but it does not appear to scan, nor does strcpy work.
I'm pretty sure that the char* in the student definition is always pointing to &name which causes all of those pointers to point to one variable. Is there a way to make each char pointer of each student point to an individual local &name?
Any help would be much appreciated