Define an integer vector and get several input from keyboard, then display the numbers in the vector. The while loop is required to write the display loop. I am having trouble turning my program into a while loop and getting mistakes. Please help.
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int x;
vector<int> temp;
cout<<"Please enter several integer numbers."<<endl;
while (cin>>x)
{
temp.push_back(x);
}
typedef vector<int>::size_type vec_sz;
vec_sz n=temp.size();
vec_sz i=0;
while(i<n)
{
cout<<temp[i]<<endl;
++i;
}
return 0;
}