c++中用push_back输入一组数字却无法继续运行程序

题目是输入一组数,然后输出相邻两个数的和。我用迭代器做出,代码如下,但是输入
一组数后敲即回车,程序没有反应,即没有出现相邻两项的和,为什么?请指教!
#include
#include

using namespace std;

int main()
{
vector vInt;
int iVal;
cout << "请输入一组数字:" << endl;
while (cin >> iVal)
{
vInt.push_back(iVal);
}
if (vInt.cbegin() == vInt.cend())
{
cout << "没有任何元素" << endl;
return -1;
}
cout << "相邻两项的和依次为:" << endl;
for (auto it = vInt.cbegin();it != vInt.cend()-1;it++)
{
cout << (*it + *(++it)) << " ";
if ((it - vInt.cbegin() + 1) % 10 == 0)
cout << endl;

}
if (vInt.size() % 2 != 0)
    cout << *(vInt.cend() - 1);
return 0;

}
附图图片说明

可以试试修改为:

cin >> iVal;
 while (iVal)    // 输入零结束 while
{
    vInt.push_back(iVal);
    cin >> iVal;
}
 while (cin >> iVal)
{
vInt.push_back(iVal);
}

这一句进入了死循环。
建议使用getline方法,获取一行的输入,然后再对这一行里面的数字进行提取,放入到vector中

cin>>的返回值是cin对象,只有当输入失败的时候才反回NULL