ورود

View Full Version : سوال: افزودن به لیست پیوندی



raaaaz
چهارشنبه 10 فروردین 1390, 18:00 عصر
سلام
این تابع برای افزودن اطلاعات مورد نظر به لیست پیوندی نوشته شده اما error میدهد:....Unhandled exception at
چرا؟
int AddStudent(char major[10],char n[30],int d,char g)
{
StudentNode *q,*t;
t=new StudentNode;
t->id=d;
for(int x=0;x<30;x++)
t->name[x]=n[x];
if(g=='f')
t->gender=t->Female;
if(g=='m')
t->gender=t->Male;
t->courseList=NULL;
if(major=="computer")
{
for(q=head1;q->id<d;q=q->next)
{
if(q==NULL)
{
q=t;
q->next=NULL;
}
else
{
t->next=q->next;
q->next=t;
}
}
}
if(major=="electronic")
{
for(q=head2;q->id<d||q==NULL;q=q->next)
{
if(q==NULL)
{
q=t;
q->next=NULL;
}
else
{
t->next=q->next;
q->next=t;
}
}
}
return 0;
}