I've created two structs:
typedef struct Student{
int id;
char* name;
int birthYear;
int finishedCourses;
int courseCredits;
double avarage;
int coursesNow;
NodeCourses* courses;
}Student;
typedef struct NodeS{
Student student;
struct NodeS* next;
}NodeS;
So I can now create a linked list of students.
one of the things I want to do is to ask the user to put details about each student.
so Ive created a function that called "addNewStudent"
first in the function it does this:
NodeS* newStudent;
newStudent=(NodeS*)malloc(sizeof(NodeS));
and than, when I am asking the user to insert a name I put it in a string called "name" and I want to malloc again the name string. so I do this:
newStudent->student.name=(char*)malloc(sizeof(char)*strlen(name));
and that line gives me segmentation fault.
ps: Ive checked the string is in the write size and that i get is correctly.
what should I do?