I want to concatenate two linked lists L1 and L2. but it didn't work when i called the concat2 on my main and only showed random numbers and ended the process. can anyone help me? i'm new to c :( thanks in advance
Here's my code:
List Concat2 (List L1, List L2){
if(IsEmpty(L2)){
return Copy(L1);
}else{
return inslast(Concat2(L1,Head(L2)),LastElmt(L2));
}
}
And here's my code for Head
and LastElmt
:
List Head (List L){
if(IsEmpty(L)){
return Null;
}else{
return info(L);
}
}
int LastElmt(List L){
address Last;
if(IsEmpty(L)){
return info(L);
}else{
Last = L;
while(next(Last)!=Null){
Last = next(Last);
}
return info(Last);
}
}
for example List L1: 1 2 3 List L2: 4 5 6 expected output: 1 2 3 4 5 6 my code output: process returned -1073741819 (0xC0000005)
User contributions licensed under CC BY-SA 3.0