Hey buddies. I have a function. it works in windows very fine but when I try to run it on my linux ssh account, it reports me segmentation fault. If someone can understand linux/ssh etc.., please help me?
void List::deleteStudent(char* num){//deletes a students record from plural linked list
student *scan,*back;//pointers
lessons *pn;//sub pointer
int counter=1;
scan=head;//moves scan to head of the linked list
char *temp;//a temp char to use for comparasions
temp=strncpy(temp,scan->num,8);
while((scan!=NULL)&&(strcmp(num,temp)>0))
{
back=scan;
scan=scan->next;
temp=strncpy(temp,scan->num,8);
counter++;
}
if(strcmp(num,temp)<0){cout<<"No record found."<<endl;}
else//record found.
{
if(scan==head)//if the record in the head of the linked list.
{
head=head->next;
pn=scan->lessonspoint;
while(pn)
{
scan->lessonspoint=pn->next;
delete pn;
pn=scan->lessonspoint;
}
delete scan;
return;
}
else//record in the anywhere else
{
back->next=scan->next;
pn=scan->lessonspoint;
while(pn)
{
scan->lessonspoint=pn->next;
delete pn;
pn=scan->lessonspoint;
}
delete scan;
}
}//end of else
}