works in windows fine, but in ssh/linux doesnt...

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?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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
}

Plural Linked List:

http://a1112.hizliresim.com/s/1/uyrg.png
1
2
char *temp;//a temp char to use for comparasions
temp=strncpy(temp,scan->num,8);

You know that's wrong, right?
Topic archived. No new replies allowed.