Q:

Why we need to fill data before linking in link list?

#include<iostream>
using namespace std;
struct Data
{
    string name;
    int age;
    string address;
    string occupation;
    struct Data *Next;
};
struct Data *Head=NULL,*Tail=NULL;

//here in my case. i am first linking Next & Head pointer before puting data in list.The code don't give any error but concept is not implemented properly.
void Add()
{
        struct Data *temp;
        temp = new Data;
        if(Head==NULL)
        {
            Head=temp;
        }else{
            temp=Tail;
        }
        cout<< "Enter Your name :";
        cin>> temp->name;
        cout<< "Enter Your Age :";
        cin>> temp->age;
        cout<< "Enter Your Address:";
        cin>> temp->address;
        cout<< "Enter Your Occupation";
        cin >>temp->occupation;

        temp->Next = NULL;
        Tail= (temp->Next) ;
}

Please explain me concept , WHY WE NEED TO PUT DATA  BEFORE CONNECTING . look at the void add() function. Read comment
 on input 1 it correctly as for data insertion, but after one cycle  next time on same input . is stop execution.

A:

The main issue is here:
temp=Tail;

You modify what temp points to before setting the data. So all the stuff after that is modifying Tail and not temp. This also leads to a memory leak.
There are other issues, like Tail always being nullptr because you need to assign it when you assign Head. Also, you are not linking in temp properly at the end.
void Add()
{
    struct Data *temp = new Data;
    if (!temp) return;

    temp->Next = nullptr;

    cout<< "Enter Your name :";
    cin>> temp->name;
    cout<< "Enter Your Age :";
    cin>> temp->age;
    cout<< "Enter Your Address:";
    cin>> temp->address;
    cout<< "Enter Your Occupation";
    cin >>temp->occupation;

    if (!Head) {
        Head = Tail = temp;
    }
    else {
        Tail->next = temp;
        Tail = temp;
    }
}

Note, you could also set the data after linking, as long as you don't modify what temp points to:
void Add()
{
    struct Data *temp = new Data;
    if (!temp) return;
    temp->Next = nullptr;

    if (!Head) {
        Head = Tail = temp;
    }
    else {
        Tail->next = temp;
        Tail = temp;
    }

    cout<< "Enter Your name :";
    cin>> temp->name;
    cout<< "Enter Your Age :";
    cin>> temp->age;
    cout<< "Enter Your Address:";
    cin>> temp->address;
    cout<< "Enter Your Occupation";
    cin >>temp->occupation;
}

