Ok, this is my function....
Code:
struct student *dodaj_di_triba(struct student *head, int mb,char *ime){
struct student *temp;
struct student *dodaj;
dodaj = (struct student *)malloc(sizeof(struct student));
dodaj->mbr=mb;
strcpy(dodaj->ime,ime);
temp = head;
while(temp->next<=dodaj->mbr){
if(temp>dodaj->mbr){
temp->next=dodaj;
}
temp=temp->next;
}
return dodaj;
}
My d. list is NOT sorted. But i just wnated to see will this work. If i enter smaller MBR then put it in front bigger one. When im going to print it, i does print it on the first place but then crashes. Does list have to be sorted for this to work?
example, i enter: John 7, Ivan 9, Mike 5, when i print this it will print in order how it was entered, in my list it enters on the first place. With this function, when I enter John 7, Ivan 9, Mike 5, and Steve 2, it does print Steve 2 first but then crashes.