我的任務是對整數數組進行硬編碼,將數組顯示給用戶,然後要求用戶輸入要搜索的整數。我的問題是獲取輸入來搜索數組。錯誤C2678:二進制'>>':沒有找到運算符類型爲'std :: istream'的左操作數的操作符。如何爲搜索索引提供輸入?
#include <iostream>
using namespace std;
int main()
{
int intArray [17] = {7, 3, 32, 2, 55, 34, 6, 13,29,22, 11, 9, 1, 5,42,39, 8};
cout << "List = 7, 3, 32, 2, 55, 34, 6, 13,29,22, 11, 9, 1, 5,42,39, 8 " << endl;
cout << "Enter an integer in the list to search for: " << endl;
cin >> intArray;
}
嘗試創建一個新的變量來讀取輸入。不要將它讀入同一個intArray。 – Barett
我該怎麼做呢? –