0
    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++;
}
2
Contributors
1
Reply
14
Views
4 Years
Discussion Span
Last Post by Banfa
0

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

i=a.begin();
while(i!=a.end())
{
  cout<<*i;
  i++;
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.