需要帮助来弄清楚为什么我的数组不保存输入
Need help to figure why my array its not saving an input?
所以这是一个船上的数据库,我的问题是我必须检查用户是否输入了一个整数,但当程序将注册表保存到数组中并显示结果时,用户放置数字的注册表变量是一个数字的加扰
int tester1 = 0;
cout << "What is the registry of the ship?: ";
cout << " >>";
if (cin >> tester1)
{
tester1 >> array[counter].registry;
cin.clear();
cin.ignore(1000, 'n');
}
else
{
while (!(cin >> tester1))
{
cout << "Please enter an integer!!" << endl;
cout << " >>";
cin >> tester1;
cin.clear();
cin.ignore(1000, 'n');
}
}
cin>>tester1;
while(!cin) {
cin.clear();
cin.sync();
cout << "Please enter an integer!!" << endl;
cout << " >>";
cin>>tester1;
}
array[counter].registry=tester1;
相关文章:
- 保存/加载大量短数组到二进制文件
- 如何在数组和向量 c++ 中存储和保存输入
- 2D 数组,某些单元格保存特定数据
- 如何在c++中将字符串中的所有数字保存到多维数组中
- 将值更改为 c++ 的数组并保存文件
- 数组不保存初始化值
- 按顺序遍历 AVL 树,将值保存在数组中
- 将 QImage 保存到字节数组
- 将特征数组行保存在变量中
- 将数组保存到二进制文件不起作用 c++
- 如何将数组保存到C 中的文件中
- C++一维Char数组保存为二维Char数组
- 如何使用相同的功能模板将3个不同的数组保存到3个不同的文件
- 通过神经网络中的函数将数据从 2D 数组保存到文件中
- HDF5:将线性数组保存到三维数据集
- 如何将排序后的数组保存在文本文件中
- 将结构的 c++ 数组保存到文件和问题中以向其添加新元素
- c++多维数组保存/加载到文件错误
- 在cpp中用2d数组保存的列长度
- 如何快速将无符号字符数组保存到图像文件