How to take user input without using -1 condition


Please check and resolve the error in my code.
Code is giving 1 less element than entered.

Hey @tgoel5884

node*take_input(){
    int d;
    // cin>>d; removed this
    node*head=NULL;
    while(cin>>d){
        insertathead(head,d);
    }
    return head;
}

Thanks, Solution worked :slight_smile:

1 Like