I am getting an error and I can't figure out what I am doing wrong. I have compared to similar code in the text book and I am still over looking something any help with what I am missing would be appreciated!
Error 1 error C2109: subscript requires array or pointer type 45 1
PHP Code:
#include "stdafx.h"
#include <conio.h>
#include <iostream>
using namespace std;
//Function prototype
int searchList (const int [ ], int);
//constant
const int NUM_ELEMS = 10;
int main()
{
// varibles
int luckyNumbers [NUM_ELEMS] = {13579, 26791, 26792, 33445, 55555, 62483, 77777, 7422, 85647,
93121};
// call the LuckyNumbers check function
searchList (luckyNumbers, NUM_ELEMS);
_getche ();
return 0;
}
// ***************************************************
// The searchList function performs a linear search on the int array
// luckyNumbers. If the number is with in luckyNumbers it will return
// message confirming the numbers are winners otherwise it it will
// notify user that the numbers are not winning numbers
// ***************************************************
void searchList (int luckyNumbers[], int NUM_ELEMS)
{
int winningNumbers = 0;
bool found = false;
cout << "Enter this weeks Winning Numbers: " << endl;
cin >> winningNumbers;
for (int i = 0; i < NUM_ELEMS; i++)
{
if (luckyNumbers[i] == winningNumbers)
{
found = true;
break;
}
}
if (found)
{
cout << "You are a winner! " << endl;
}
else
{
cout << "Sorry better luck next week. /n ";
}
}