#include <iostream>
using namespace std;
int vowels[] = {65, 69, 73, 79, 85, 97, 101, 105, 111, 117}; // ASCII codes (upper & lower case).
bool characterInArray(char letter, int arr[]) {
return find(begin(arr), end(arr), (int) letter) != end(arr);
}
int main() {
if (characterInArray('i', vowels)) {
cout << "Found a vowel in the character provided." << endl;
}
return 0;
}
Given this code, I'm given an error "error: no matching function for call to "begin". The full error message is below, what am I doing wrong here?
candidate template ignored: could not match 'initializer_list<type-parameter-0-0>' against 'int *'
bool characterInArray(char letter, int *arr)
. That should explain the error you're getting.'A'
etc. It's much clearer.