I'm trying to see if an array contains a given letter. If the array doesn't have the letter, then we add it to the array. I know how to do this in python with the not in arr
syntax, but having a lot of trouble with the c++ method.
This is the python code:
vowel_arr = []
#Checks
for i in arr:
if len(i)>input_pos and i[input_pos] not in vowel_arr:
vowel_arr.append(i[input_pos])
This is my C++ code attempt:
word_arr = [ 'c', 'co', 'cmo', 'cmop','cmopu','cmoptu', 'cemoptu', 'cemoprtu']
input_pos = 2
vowel_arr = [o,m,e]
//Creates a list that contains unique letters for a given position
vector <char> unique_arr;
for(int j = 0; j < word_arr.size(); j++){
if ((word_arr[j].size() > input_pos) && (find(unique_arr.begin(),
unique_arr.end(), word_arr[j][input_pos]) == unique_arr.end())){
unique_arr.push_back(word_arr[j][input_pos]);
}
}