所以這是一個船舶的數據庫,我的問題是,我必須檢查用戶是否輸入一個整數,但是當程序將註冊表保存到數組中時,我將顯示結果註冊表變量,其中用戶將該數字置爲一個爭用數需要幫助來確定爲什麼我的數組沒有保存輸入?
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');
}
}
'tester1 >>陣列[計數器] .registry;'那是什麼?請發佈[最小,完整和可驗證示例](http://stackoverflow.com/help/mcve)。 –
tester1抓取用戶輸入並檢查是否爲int,因此如果是int,則tester1將其保存到數組中,使用 –
tester1 >> array [counter] .registry; –