需要帮助来弄清楚为什么我的数组不保存输入

Need help to figure why my array its not saving an input?

本文关键字:数组 保存 输入 我的 为什么 帮助 弄清楚      更新时间:2023-10-16

所以这是一个船上的数据库,我的问题是我必须检查用户是否输入了一个整数,但当程序将注册表保存到数组中并显示结果时,用户放置数字的注册表变量是一个数字的加扰

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;