mercredi 30 mai 2018

C++ : Vectors in Structure

enter image description here **Problem Is that when I run Program it donot ask for first persons first name.. After that it asks every thing. **

int main()
{
    int a;
    cout<<"How Many Persons data you want to Enter ?";
    cin>>a;
    vector<data> persons;
    cout<<"\n\n\t\t\t\t First Name , Last Name and CNIC Number \n\n";
    for(int i=0;i<a;i++)
    {
        persons.push_back(data());
        cout<<"Please Enter First Name of Person "<<i+1<<" :  ";
        getline(cin,persons[i].fn);
        cout<<"Please Enter Last Name of Person "<<i+1<<" : ";
        getline(cin,persons[i].ln); 
        persons[i].full_name=persons[i].fn+persons[i].ln;
    }

Aucun commentaire:

Enregistrer un commentaire