0
안녕하세요, 변수를 유지하는 방법을 lastWordLoaded
이라고 말하면서 word
이 될 사전에로드되는 다음 단어와 비교해보십시오.변수를 비교하는 데 사용하려면 어떻게해야합니까?
lastWordLoaded> CurrentWord 인 경우 -1을 인쇄하는 방법 compareWords
이 있습니다. 따라서 lastWordLoaded> CurrentWord 인 경우 알파벳순이 아님을 의미합니다. lastWordLoaded 인 경우 < CurrentWord는 0을 출력하므로 0 인 경우 파일이 알파벳순입니다. 이 상황에서 lastWordLoaded
을 어떻게 사용할 수 있는지 확신 할 수는 없지만.
Dictionary::Dictionary() {
//check if the file was opened
if (dictionaryFile.is_open()) {
while (getline(dictionaryFile, word) &&
getline(dictionaryFile, definition) &&
getline(dictionaryFile, type) &&
getline(dictionaryFile, blank)) {
myWords[wordCount] = fromRecord(word, definition, type);
if (compareWords(word, lastWordLoaded) != 0)
{
cout << "\nThe dictionary isnt in alphabetical order." << endl;
cout << "Error at word = " << getWordCount() << endl;
system("Pause");
}
}
//close the file
dictionaryFile.close();
}
이 왜 우리에게 쉽게하지 않는다 코드의 일부? – HAL
, 죄송합니다. – user2881555
왜 "else lastWordLoaded = word;"를 할 수 없습니까? –