Why is it not working?

int length1=0,length2=0;
Node* temp1=l1;
Node* temp2=l2;
while(temp1!=NULL){
temp1=temp1->next;
length1++;
}
while(temp2!=NULL){
temp2=temp2->next;
length2++;
}

temp1=l1;
temp2=l2;
if(length1>length2){
    int count=length1-length2;
    while(count--){
        temp1=temp1->next;
    }
}
else{
    int count=length2-length1;
    while(count--){
        temp2=temp2->next;
    }
}

while(temp1!=temp2){
    temp1=temp1->next;
    temp2=temp2->next;
}
return temp1;

I can’t understand you code, if you paste your code on ide.codingblocks.com and save it and then send it to me, then its good to understand.

I have Provide you the reference Code for this question below :
try to understand it…
if you have further doubt then feel free to ask:

Reference code :