Can i get some Help with this..Not sure I have tried different data types still not working
1 2 3 4 5 6 7
int index;
//char test; did not work
//string result; did not work
for(int i=0;i<word1.size();i++){
index = find(letters.begin(), letters.end(), word1[i]);//'=': cannot convert from 'std::_Vector_iterator<std::_Vector_val<std::_Simple_types<char>>>' to 'int'
}
You can calculate the index by subtracting the begin() iterator. If nothing was found the end iterator is returned so don't forget to check that before doing anything with the iterator.
1 2 3 4 5 6 7 8 9
std::vector<char>::iterator it = find(letters.begin(), letters.end(), word1[i]);
if (it != letters.end())
{
index = it - letters.begin();
}
else
{
// The letter was not found!
}