Hi ,is there anybody,who can help me with this code
Code:
#include <stdio.h>
#include <stdlib.h>
typedef
struct students
{
int ID;
char *Name;
float GPA;
struct students *Next;
}record;
void insert(record *pr,int id,char *n,float sc);
void printList(record *ptr_head);
int main()
{
record *ptr_head=NULL;
insert(&ptr_head,1111,"Jimi",80.6);
printList(ptr_head);
getch();
return 0;
}
void insert(record *pr,int id,char *n,float sc)
{
record head;
record tail;
record curr;
head=malloc(sizeof(record));
if (head != NULL)
{
head->ID=id;
head->Name=n;
head->GPA=sc;
head->Next=NULL;
tail=NULL;
curr=*pr;
while (curr!=NULL && value >curr->ID)
{
tail=curr;
curr=curr->Next;
}
if (tail==NULL)
{
head-> Next=*pr;
*pr=head;
}
else
{
tail->Next=head;
head->Next=curr;
}
}
else
{
printf("%c not inserted.No memory avalible",value);
}
}
void printList(record *ptr_head)
{
while(ptr_head){
printf("%5d : %10s : %2.3f \n",ptr_head->ID,ptr_head->Name,ptr_head->GPA);
ptr_head =ptr_head->Next;
}
}