So, zen, what I have to do in main is correct it from:
Code:
int main()
{
int test;
char strline[10];
/* first head struct of student */
struct student *init_stud, *temp;
init_stud = malloc(sizeof(struct student));
/* etc..... */
to this:
Code:
int main()
{
int test;
char strline[10];
/* first head struct of student */
struct student *init_stud, *temp;
init_stud = malloc(sizeof(struct student));
init_stud = NULL; /* Must make NULL, right? */
/* etc... */
And then in the function where I add the new list to linked list, I'll have to change it from:
Code:
void addstud(struct student *head_stud, struct student *insert_stud)
{
struct student *temp_stud; /* temporary stud to walk with */
temp_stud = malloc(sizeof(struct student));
/* loop to get to the last list */
while (1)
{
if (temp_stud == NULL)
break;
else
temp_stud = temp_stud->next_student;
}
temp_stud->next_student = insert_stud;
}
to this:
Code:
void addstud(struct student *head_stud, struct student *insert_stud)
{
insert_stud->next_stud = NULL; /* next instance NULL */
struct student *temp_stud; /* temporary stud to walk with */
temp_stud = malloc(sizeof(struct student));
/* loop to get to the last list */
while (1)
{
if (temp_stud == NULL)
break;
else
temp_stud = temp_stud->next_student;
}
temp_stud->next_student = insert_stud;
}
Right? So then when I add another student, the next pointer (*next_stud) will equal NULL until another linked list is added on. Is this correct? Are these changes valid? Thanks so much. I really owe you one, zen.
--Garfield