Мне нужен этот код для чтения каждой строки цикла, однако он читает только первую строку.Он извлекает из файла, в котором всего девять зашифрованных слов, и должен прочитать все девять и расшифровать их, чтобы сделать четырехбуквенные слова.Есть предложения?
position = 0;
test_word = puzzle;
cout << "Is " << test_word << " a word? " << endl;
while (!wordpuzzle.eof())
{
for (int i = 0; i < puzzle.length(); i++);
{
while (position <= puzzle.length() - 4)
{
test_word = puzzle.substr(position, 4);
cout << "Is " << test_word << " a word? " << endl;
while (!dictionary.eof()) // Loop through dictionary comparing each word.
{
dictionary >> word; // Get a word from the dictionary
counter++;
if (word == test_word)
{
cout << "The word " << test_word << " was found in the scramble. "
<< " Word " << counter << endl;
found = true;
break; // Exit while loop if word is found
}
}
while (!dictionary.eof()) // Loop through dictionary comparing each word.
{
dictionary >> reverseword; // Get a word from the dictionary
counter--;
if (reverseword == test_word)
{
cout << "The word " << test_word << " was found in the scramble. "
<< " Word " << counter << endl;
found = true;
break; // Exit while loop if word is found
}
}
if (!found)
cout << "The string " << test_word << " is not a word." << endl;
dictionary >> word;
// Reset everything for the next substring from the scramble.
dictionary.clear();
dictionary.seekg(0, ios::beg);
position++;
counter = 0;
found = false;
}
}
}
cout << endl << endl;
dictionary.close();
system("pause");
return 0;
}