-2
필자가 작성한 클래스 메서드는 단어를 다른 배열에 저장해야하지만 파일이 성공적으로 읽혔는지 여부에 대한 부울을 반환해야합니다. 논리 오류를 찾을 수 없습니다.bool 함수가 true 또는 false를 반환하지 못함
내가 공간도 여기에이misspelledword correctword correctword correctword
처럼 될 수있는 탭
misspelledword correctword
misspelledword2 correctword2
misspelledword3 correctword3
하지만 형식으로 구분되어 이런 일에 읽고있다 파일의 형식은 내 코드
의
bool SpellChecker::loadFile(string filename)
{
ifstream ifile;
ifile.open(filename.c_str());
if (ifile.fail())
{
cout << "Error opening file" << endl;
return false;
}
string line;
int count = 0;
while (getline(ifile, line))
{
istringstream iss(line);
getline (iss, misspelled[count], '\t');
getline (iss, correct[count]);
count++;
}
if (ifile.good())
{
return true;
}
ifile.close();
}
false 또는 true를 반환하지 않아야하는 이유는 확실하지 않지만 임의의 수를 반환합니다. R 17, 그것이 어디서 왔는지 확실하지 않습니까?
. 또한 'bool'은 '17'을 포함 할 수 없습니다. [mcve]를 게시하십시오. – Rakete1111
컴파일러에서 경고를 표시해야합니다. 그렇지 않은 경우 경고 수준을 켜거나 켭니다. – chris