Let's say i have a student struct defined:
stuct student {
struct Student *next;
};
typedef struct student Student
Now I have the following function:
void add_student(Student **student_list_ptr) {
Student *new_s;
new_s = malloc(sizeof(Student));
// I want to insert this first the new_s into the student_list_ptr
// I did this but it gives me a segmentation fault
Student *current = *student_list_ptr;
if (current->next == NULL){
current->next = new_s;
}
}
I want to insert this first the new_s
into the student_list_ptr
I did this but it gives me a segmentation fault.