for(i=a.begin();i!=a.end();i++)
    {
    cin>>*i;    
    }
        for(i=a.begin();i!=a.end();i++)
    {
    cout<<*i; 
    }


above code works fine but when i use while loop to display vector ,  program crash.



while(i!=a.end();)
{
cout<<*i;
i++;
}

What was i initialised to before the loop started? This should work

i=a.begin();
while(i!=a.end())
{
  cout<<*i;
  i++;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.