Problem

Why does this program only print the first entered value and the push_back value?


#include <iostream>
#include <vector>
using namespace std;

int main ()
{
vector<int> val(1);
vector<int>::iterator vali = val.begin();
while(cin>>*vali)
{
val.push_back(NULL);
vali++;
}
vali = val.begin();
while(vali != val.end())
{
cout << *vali << endl;
vali++;
}
return 0;
}
Topic archived. No new replies allowed.