Garbage value in output


please check my code

hi @lakshay2311

they are not garbage they are addresses

void print(node*&head){
    while(head!=NULL){
        cout<<head->next<<"->";
        head=head->next;
    }
    cout<<endl;
} 

instead of head->next you should write

head->data

i hope this help
if you have more doubts regarding this feel free to ask
if your doubt is resolved mark it as resolved from your doubt section inside your course

1 Like