Word wheel: Difference between revisions

Content added Content deleted
(New post which does not use external libraries, in addition to an existing post which uses the "Boost" library.)
m (Changed two variable names.)
Line 1,166: Line 1,166:
}
}


for ( const std::string& word : correct_words ) {
for ( const std::string& correct_word : correct_words ) {
std::cout << word << std::endl;
std::cout << correct_word << std::endl;
}
}


Line 1,192: Line 1,192:
bool valid_word = true;
bool valid_word = true;
for ( const char& ch : word ) {
for ( const char& ch : word ) {
std::vector<char>::iterator iterator = std::find(letters.begin(), letters.end(), ch);
std::vector<char>::iterator iter = std::find(letters.begin(), letters.end(), ch);
int32_t index = iterator == letters.end() ? -1 : std::distance(letters.begin(), iterator);
int32_t index = ( iter == letters.end() ) ? -1 : std::distance(letters.begin(), iter);
if ( index == -1 ) {
if ( index == -1 ) {
valid_word = false;
valid_word = false;